Path: utzoo!attcan!uunet!taumet!steve From: steve@taumet.COM (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: general routine for calendar application... Keywords: calendar, Zeller Message-ID: <221@taumet.COM> Date: 27 May 90 21:22:59 GMT References: <9270.643838242@ics.uci.edu> Reply-To: steve@taumet.UUCP (Stephen Clamage) Organization: Taumetric Corporation, San Diego Lines: 22 In article <9270.643838242@ics.uci.edu> jman@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@taumet.com