This is an old revision of this page, as edited by 24.80.97.229 (talk) at 00:46, 7 December 2004. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Revision as of 00:46, 7 December 2004 by 24.80.97.229 (talk)(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)The Doomsday algorithm is a way of calculating the day of the week of a given date. It is perpetually accurate since the Gregorian calendar moves in cycles of 400 years. It makes use of the fact that, in each year, certain dates are all on the same day of the week.
The algorithm has three steps, namely, finding the anchor day for the century, finding a year's doomsday, and finding the day of week of the day in question.
To find a century's anchor day, begin by finding the century which the date falls in. (For the purposes of this calculation, century years will be treated as though they fall in the century that follows, even though they technically fall in the same century as the years before them. 2000 is therefore part of the twenty-first century, not the twentieth century.) A year's century number is equal to its first two digits plus one (so 1966 is in the twentieth century). Take the century number and multiply by 5. Next, take the integral part of the quotient when the century number minus one is divided by four and add the two numbers. (Taking the remainder mod 7 is often done, since it won't affect the result.) Now count forward that number of days from Wednesday to get the anchor day for the century.
Next, one must find the year's Doomsday. To accomplish that according to Conway, begin by taking the integral part of the quotient when the last two digits are divided by 12. Next, determine the remainder of this first quotient. After that, take the integral part of this number when it is divided by 4. Finally, determine the sum of the three numbers.
Now count forward the specified number of days from the anchor day (again taking remainder mod 7 can be done) to get the year's Doomsday.
The following days all occur on Doomsday for any given Gregorian year.
January 3 (or January 4 for leap years) February 28 (or February 29 if it's a leap year) "March 0" (a backwards extension of the calendar, equivalent to the last day of February.) April 4 May 9, June 6 July 11, August 8 September 5, October 10 November 7, December 12
The dates listed above were chosen to be easy to remember; the ones for even months are simply doubles, 4/4, 6/6, 8/8, 10/10, and 12/12. Four of the odd month dates (5/9, 9/5, 7/11, and 11/7) are based on the phrase "I work from 9 to 5 at the 7-11."
For dates in March, March 7 falls on Doomsday, but the pseudodate "March 0" is easier to remember, as it is necessarily the same as the last day of February.
Therefore, if you know what day of the week Doomsday — the last day in February — is for a given year, you can easily determine the day of the week for any other date in that year, by finding the nearest Doomsday.
The Doomsday algorithm was invented by John Horton Conway. It can be used for either the Gregorian Calendar or the Julian Calendar, but note that Julian calendar Doomsdays usually occur on different days from the Gregorian calendar Doomsdays.
An example
Suppose you want to know which day of the week April 17 2004 is. In the year 2004, Doomsday is Sunday. (The century's anchor day is Tuesday and 2004's Doomsday is five days beyond.) This means that April 4 is also Sunday, so April 18 is a Sunday as well (since it's two weeks after April 4). April 17, being the day before it, must be a Saturday.