[EMAIL PROTECTED] (John Machin) writes: > [EMAIL PROTECTED] (Mark Jackson) wrote in message news:<[EMAIL PROTECTED]>... > > > > A: 42 > > > > Q: What multiple of 7 did I add to the critical expression in the Zeller > > algorithm so it would remain nonnegative for the next few centuries? > > What are you calling "the Zeller algorithm", and what is the "critical > expression"?
A C function in calendar.c, encountered in the source code for xvtdl: int zeller (month, day, year) int month, day, year; { int century; month -= 2; /* Years start on March 1 so adjust standard date */ if (month < 1) { month += 12; year--; } century = year / 100; year = (int)year % (int)100; return ((int)((2.6 * month - 0.1) + day + year + year / 4 + century / 4 - century * 2) % 7); } The expression upon which "% 7" acts is negative when "year" is small. This caused errors beginning in March 2000; which could be deferred by adding a suitably-large multiple of 7 to the expression. The choice was obvious. :-) > I've no doubt you came across a stuffed-up date-to-days calculation > routine and fixed it, but it's a bit unfair to lumber Zeller with the > blame. If it was a days-to-date routine, then Zeller is not even > standing next to the real target. Fair enough, although I'm not responsible for having named the function (which appears to date from 1991). The original author is identified in the code (available at http://www.alumni.caltech.edu/~mjackson/xvtdl.html) and is findable via the Web; you might take the matter up with him. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson People who write obscurely are either unskilled in writing or up to mischief. - Sir Peter Medawar -- http://mail.python.org/mailman/listinfo/python-list