Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!caip!pyrnj!mirror!rayssd!dhb From: dhb@rayssd.UUCP (David H. Brierley) Newsgroups: net.unix Subject: Re: Re: Re: Adding Time and Date Message-ID: <127@rayssd.UUCP> Date: Sun, 7-Sep-86 01:05:20 EDT Article-I.D.: rayssd.127 Posted: Sun Sep 7 01:05:20 1986 Date-Received: Sun, 7-Sep-86 05:12:06 EDT References: <118@funvax.UUCP> <492@hdsvx1.UUCP> Sender: dhb@rayssd.UUCP (David H. Brierley @ Raytheon Co., Portsmouth RI) Organization: Raytheon Co., Portsmouth RI Lines: 23 > > Is there also a simple routine that will allow me to calculate > > what day of the week an arbitrary date falls on? > > Bruce > Real simple. Just take any day as a reference point, note its Julian > Day and the day of the week on which it fell. To find the day of the > week for some other day, take the difference between the two Julian > Days, mod 7. That's all well and good but you have not addressed the question of getting the date into Julian in the first place which is not exactly trivial (although admittedly not very difficult). What I dont understand is why no one has suggested using Zeller's congruence? Is this simple yet extremely useful algorithm considered second rate? Or is it just that no one is familiar with it? I dont have the source code in front of me but basically the algorithm takes the month, day of the month, century, and year of the century and outputs the day of the week. The whole thing is only a couple of lines of C code. If anybody is interested and doesn't have a reference available with the algorithm in it, send me mail and I will send you a working version of the algorithm written in C. -- Dave Brierley; Raytheon Co.; Portsmouth RI; (401)-847-8000 x4073 { allegra, gatech, ihnp4, linus!raybed2 } !rayssd!dhb