[net.followup] Date Algorithm

lmaher@uokvax.UUCP (01/23/84)

#R:sequent:-33700:uokvax:2700015:000:661
uokvax!lmaher    Jan 21 15:25:00 1984

(posting from a friend's account while uok is down)
For calculating the day of the week, here's Zeller's Congruence:

F = (int((26*m-2)/10) + k + d + int(d/4) + int(c/4) - 2*c) mod 7

F=0 is Sunday, F=1 is Monday, and so on
k is the day of the month, c is centuries, d is year in the century,
m is the month starting with March as 1, April as 2, on to February
as 12. int(x) is the largest integer smaller than x, of course.

Example:  8/20/1982 - k=20,c=19,d=82,m=6
F= (int(15.4) + 20 + 82 + int(20.5) + int(4.75) - 38) mod 7
  = (15+20+82+20+4-38) mod 7
  = 103 mod 7
  = 5
so August 20, 1982 was a Friday.

	Carl
	..!uokvax!uok!crigney 
	..!duke!uok!crigney

foertsch@uiucuxc.UUCP (01/28/84)

#R:sequent:-33700:uiucuxc:3300047:000:267
uiucuxc!foertsch    Jan 27 13:17:00 1984

Warning: In the preceding congruence, January and February are considered to
be the last two months of the previous year!!!!  This means that c and d as well
as m must be adjusted from their conventional numberings in order to apply
the formula given.

Kurt Hirchert

bill@utastro.UUCP (William H. Jefferys) (02/06/84)

The question was whether common date algorithms will die in the
year 2000.  Actually, probably not since, unlike the century
years 1700, 1800 and 1900, the year 2000 *is* a leap year.  2100
is *not* a leap year, so if one has naively programmed the date
algorithm to count a leap year every 4 years, it is likely that
it will work until then.
-- 

	Bill Jefferys  8-%
	Astronomy Dept, University of Texas, Austin TX 78712   (USnail)
	{ihnp4,kpno,ctvax}!ut-sally!utastro!bill   (uucp)
	utastro!bill@ut-ngp			   (ARPANET)