Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!nbires!vianet!devine From: devine@vianet.UUCP (Bob Devine) Newsgroups: net.lang.c Subject: Re: Calendar Functions (simpler lea Message-ID: <37@vianet.UUCP> Date: Wed, 24-Sep-86 18:36:04 EDT Article-I.D.: vianet.37 Posted: Wed Sep 24 18:36:04 1986 Date-Received: Thu, 25-Sep-86 05:03:48 EDT References: <34@vianet.UUCP> <86900058@haddock> Organization: ViaNetix, Inc., Boulder, CO Lines: 31 haddock!karl (Karl W. Z. Heuer) writes: [ that my suggestion of only checking if the year is divisible by four assumes "the test is for the current year" and that "For a general purpose algorithm (as per the original request), Dave's code is correct."] Not quite right. I said just testing by use of "year % 4" is perfectly fine for most uses (this is sort of like generic products.) However, if you want to test for years outside the range of 1901-2099 it doesn't work. The UNIX value returned by the time() system call only covers the years 1970 +/- 67 years which falls nicely in the range. The time() call is unlikely to change. If your system doesn't do it this way or you need a larger range, don't use the simple test! A general purpose algorithm must also take care of years before the Gregorian calendar system was adopted by a country. Any KGB agents out there that are reading this be sure to handle the years before 1918 differently :-) So, the posted general purpose algorithm is not comprehensive in its handling of years. My initial posting simply indicated that if you are not going to comprehensive, at least be a little faster. > I believe the quadrimillennium correction was never officially adopted. > It's not accounted for in cal(1). I'll check into the official rules; 'cal' is not a definite source. The Gregorian calender is about 1/2 minute too long compared to the solar calendar which was quite close considering it was done by a 16th century astronomer. That means that there needs to be a day added in, oh, about 3,000 years. Be sure to mark the date :-) Bob Devine