Subject: Day of the week
Date: Sat, 29 Mar 1997 21:51:37 -0500
From: Alexander Bogomolny

Haven't you placed yourself between the hammer and anvil?

Must tell you I saw formulae reminding of the one you cite (which is probably meaningless because the variables are not what one would expect - (y)ear, (m)onth, (d)ay.) I never was into this kind of things. Whatever the formula is it's trivial.

Think of what is involved. If there were no leap years, everything would be trivial, right? Just start somewhere (at the date you know) and cycle everything modulo 7 (since your formula lacks this operation, I suspect it's wrong.) Every year would have 365 days which is 1 modulo 7. In such a simpified case, if 3/29/97 is Saturday, then 3/29/96 was Friday while 3/29/98 will be Sunday.

Now because we do have leap years things are not that simple. Having sometimes 366 day years (=2 modulo 7) we'll have to add from time to time 2 instead of 1. How often? Every 4th year (this is where a term (y-1)/4 may come from.) But every hundredth year is not leap. So we should take back (y-1)/100. Among those that end in 00, every fourth is still leap. Thus we introduce the term (y-1)/400.

I do not believe you need anything deeper than the above. As I said, the formula is probably trivial.

Best regards

|Reply| |Up| |Exchange index| |Contents| |Store|

Copyright © 1996-2018 Alexander Bogomolny

71546892