Path: utzoo!attcan!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Date functionality Message-ID: <357@taumet.com> Date: 28 Jul 90 21:54:18 GMT References: <171@ittc.wec.com> Organization: Taumetric Corporation, San Diego Lines: 20 fpb@ittc.wec.com (Frank P. Bresz) writes: > I am looking for an algorithm to give me the day of the week when >handed the current date. I can't use any builtin routines from any OS >(this is targeted for a real brain-damaged machine). Here is an algorithm known as Zeller's congruence. 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 and each division is truncating division, and cannot be combined. -- Steve Clamage, TauMetric Corp, steve@taumet.com