[comp.lang.asm370] leap years, julian date, and stuff.

PERAINO@GMUVAX.BITNET (01/05/90)

Recently someone posted the "rexx" code for  a "Tableless Date Conversion".
Since we're sort of on the subject, I have been looking for an algorithm
to calculate the  day-of-week from the date. If anyone has this
algorithm, could you please send me the pseudo code directly? I do
not subscribe to this group. Thank you so much.  -Bob Peraino

peraino@gmuvax
uunet!pyrdc!gmu90x!peraino
peraino@gmuvax.gmu.edu

Z8WGH@SCFVM.BITNET (Bill Hecox) (01/05/90)

>Since we're sort of on the subject, I have been looking for an algorithm
>to calculate the  day-of-week from the date. If anyone has this
>algorithm, could you please send me the pseudo code directly? I do
>not subscribe to this group. Thank you so much.  -Bob Peraino


I have always used this method.

The last two digits of the year
Plus the Julian day divided by 4 (round up)
Plus the julian day (1 to 366)
Divide all this by 7
Remainder of 0 = SAT
             1 = SUN


This method will work until Dec 31, 1999

The method works on the idea that the first day of this century was
a specific day of the week. Jan 1, 1900

The current year is added because there is one more day in each year
since 1900 then there is a multiple of seven. I.E. 7 X 52 = 364 + 1 = 365

The current year divided by 4 (rounded up) is used to account for the
extra day in each leap year since 1900.

The Julian day is added to account for the offset into the current year.

I would be interested in seeing other methods. Also methods that will
work past the end of the century.


Regards;
Bill Hecox