Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site sdcc3.UUCP
Path: utzoo!watmath!clyde!bonnie!akgua!sdcsvax!sdcc3!33500911
From: 33500911@sdcc3.UUCP (James Hayes)
Newsgroups: net.sources
Subject: Re: Algorithm wanted
Message-ID: <2519@sdcc3.UUCP>
Date: Tue, 4-Dec-84 22:39:08 EST
Article-I.D.: sdcc3.2519
Posted: Tue Dec  4 22:39:08 1984
Date-Received: Thu, 6-Dec-84 05:15:58 EST
References: <515@uwmacc.UUCP>
Reply-To: 33500911@sdcc3.UUCP (James Hayes)
Distribution: net
Organization: U.C. San Diego, Academic Computer Center
Lines: 28
Summary: 

>    Does someone "out there" know of an algorithm (or can direct me
>to a source) which will calculate the Day of the Week (e.g. Monday,
>Tuesday, etc) based on the month, the day and the year?
>It will be greatly appreciated....
>            - Rob DeMillo
>              Madison Academic Computing Center

Sorry Folks, it's in BASIC...

X=INT(.6+1/M) : Y1=Y-X : M1=M+12*X : X=Y1/100
N4=INT(X/4) : N3=INT(X) : N2=INT((5*Y1)/4) : N1=INT(13*(M1+1)/5)
X=N1+N2-N3+N4+D-1
FD=X-(7*INT(X/7))

On entry:  Y=year (must be after 1752)
	   D=day
	   M=month

On exit:   FD will contain an integer from 0 to 6. 0=Sunday and
						   6=Saturday.
                       (And as you might have guessed 1-5 fall
			in-between.)

			James Hayes
			{ucbvax,sdcsvax}!sdcc3!33500911


[SPEED ISN'T EVERYTHING. YOU HAVE TO BE CORRECT SOME OF THE TIME]