Re: Calender program
From: Dr John Stockton (spam_at_merlyn.demon.co.uk)
Date: 01/31/05
- Previous message: Dr John Stockton: "Re: Findfirst findnext"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Jan 2005 23:35:52 +0000
JRS: In article <32F59E6E.5675@alcatel.no>, dated Mon, 3 Feb 1997
09:14:38, seen in news:comp.lang.pascal.borland, Sven Pran
<Sven.Pran@alcatel.no> posted :
>A very handsome algorithm valid for any year in the Gregorian calendar
>is:
>
>Function DOW(y,m,d : word)word;
>begin
>if m < 3
> then
> begin
> m := m+12;
> y := y-1;
> end;
> DOW := (((3*m + 3) div 5) + 2*m + d + y + (y div 4) - (y div 100) + (y
>div 400)) mod 7;
>end;
>
>The answer is 0 for Monday through 6 for Sunday.
>
>I hope I got the typo correct! The algorithm showed up here a couple of
>months ago,
>I am sorry I don't remember the author, so I can't give him proper
>credit.
I don't know who wrote the Pascal; but the algorithm is substantially
that of Zeller <URL:http://www.merlyn.demon.co.uk/zeller-c.htm> . It
can be improved by following Zeller more closely and putting 2*m inside
div 5, merging to 13*m. Needs a final +1 for ISO 8601 numbers.
NG line reduced.
-- © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. © Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
- Previous message: Dr John Stockton: "Re: Findfirst findnext"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]