Adding Time and Date

David H. Brierley dhb at rayssd.UUCP
Sun Sep 7 15:05:20 AEST 1986


> > 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



More information about the Comp.unix mailing list