Dates and Times

ron crocker crocker at ihwpt.UUCP
Fri Sep 5 12:03:31 AEST 1986


> Is there also a simple routine that will allow me to calculate
> what day of the week an arbitrary date falls on?

This is from the back of my calendar, and it still sounds like
magic to me, but it works...

(From "The Ready Reference (r) Weekly Planner 1986 ((c) 1986 Ready
Reference)
 
"To Find Day of Week of Any Date

This formula is correct for any date after September 14, 1752

EXAMPLE - WHAT DAY OF WEEK WAS JANUARY 10th, 1946?

(1) Take the last two digits of the year			[46]

(2) Add a quarter of this number, neglecting any remainder	[11]

(3) Add the date in the month					[10]

(4) Add according to the month -				[ 1]
	Jan - 1 (Leap: 0)	May  - 2	Sept - 6
	Feb - 4 (Leap: 3)	June - 5	Oct  - 1
	Mar - 4			July - 0	Nov  - 4
	Apr - 0			Aug  - 3	Dec  - 6
	
(5) Add for the Century -					[ 0]
	18th - 4	19th - 2
	20th - 0	21st - 6
	
							[Total:  68]
(6) Divide total by 7 - Remainder gives the day		[68mod7 = 5]
	1 - Sunday	2 - Monday	3 - Tuesday
	4 - Wednesday	5 - Thursday	6 - Friday
	7 - Saturday
	
ANSWER - THURSDAY"

Ok, so it's magic.  It seems to work.  For later than 21st century,
I would suggest trial/error method - there are only 7 choices...

-- 
Ron Crocker
AT&T Bell Laboratories
Room IH 6D535
Naperville-Wheaton Road
Naperville, IL  60566

(312) 979-4051



More information about the Comp.unix mailing list