general routine for calendar application...
Stephen Clamage
steve at taumet.COM
Mon May 28 07:22:59 AEST 1990
In article <9270.643838242 at ics.uci.edu> jman at ICS.UCI.EDU writes:
>
>Is there anybody in the net who might have a routine for calculating
>the day of the week given an arbitrary date.
Here is an algorithm known as Zeller's congruence. It may be of
general interest, so I am posting it. I found it in a magazine (I
forget which one) a few years ago.
The day of the week (0 = Sunday) is given by
W = ((26*M - 2) / 10 + D + Y + Y/4 + C/4 - 2*C) % 7
where
C is the century
Y is the last two digits of the year
D is the day of the month
M is a special month number, where Jan and Feb are taken as
month 11 and 12 of the previous year
Each division is truncating division, and the terms cannot be combined.
--
Steve Clamage, TauMetric Corp, steve at taumet.com
More information about the Comp.lang.c
mailing list