Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site gitpyr.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!gatech!gitpyr!roy From: roy@gitpyr.UUCP (Roy J. Mongiovi) Newsgroups: net.sources Subject: Re: Algorithm wanted Message-ID: <412@gitpyr.UUCP> Date: Sat, 8-Dec-84 14:53:05 EST Article-I.D.: gitpyr.412 Posted: Sat Dec 8 14:53:05 1984 Date-Received: Sun, 9-Dec-84 06:27:26 EST References: <2519@sdcc3.UUCP> <600@burl.UUCP> Organization: Georgia Institute of Technology, Atlanta, GA Lines: 35 > Make sure that whatever algorithm you get takes the following > into account about leap years: > > a) Any year divisible by 4 is a leap year, unless > b) it is divisible by 100 as well, in which case it is NOT a leap > year, unless > c) it is divisible by 400 as well, in which case it is a leap year > after all. > > What stupid rules! What do you mean "what stupid rules!" ? It happens to be an approximation of the ratio of the time it takes the earth to rotate around the sun to the time it takes it to rotate on its axis. Perhaps we should change one or the other of those numbers to make the approximation more esthetic? :-) Also, you can carry the approximation one place further (if for any reason you would need to) by taking into account that if the year is divisible by 4000, then it isn't a leap year after all. On a slightly different track, you can determine the number of days preceeding the beginning of a particular month by looking it up in a table, or by using an interesting method known as Zeller's Congruence. If you consider a year to start on March 1 and continue through February 28 (or 29), it forms a pattern which can be approximated to enough accuracy to ensure accurate results (all the error is in the fraction). The number of days preceeding the beginning of month N is (153 * N + 2) / 5 when computed with integer operations. The table is probably the better idea, but Zeller's Congruence rather appeals to me somehow.... -- Roy J. Mongiovi. Office of Computing Services. User Services. Georgia Institute of Technology. Atlanta GA 30332. (404) 894-6163 ...!{akgua, allegra, amd, hplabs, ihnp4, masscomp, ut-ngp}!gatech!gitpyr!roy Who me? I'm not even a REAL modo, I'm only a quasi-modo.