Misplaced Pages

Doomsday rule: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editNext edit →Content deleted Content addedVisualWikitext
Revision as of 14:13, 2 September 2005 edit80.136.247.108 (talk) +de:← Previous edit Revision as of 18:29, 5 September 2005 edit undoWikidSmaht (talk | contribs)Extended confirmed users, Pending changes reviewers2,819 edits Clarification+simple representation. Was written with math terms like "remainder mod 7" and potentially hard for a reader uneducated or rusty in mathematics to understand.Next edit →
Line 1: Line 1:
The '''Doomsday rule''' is a way of ] of a given date. It is perpetually accurate since the ] moves in cycles of 400 ]. It makes use of the fact that, in each year, certain dates are all on the same day of the week. The '''Doomsday rule''' is a way of ] of a given date. It is perpetually accurate since the ] moves in cycles of 400 ]. It makes use of the fact that, in each year, certain dates are all on the same day of the week.


The ] was invented by ]. It can be used for either the ] or the ], but note that Julian calendar Doomsdays usually occur on different days from the Gregorian calendar Doomsdays. The ] was invented by ]. It can be used for either the ] ] or the ], but note that Julian calendar Doomsdays usually occur on different days from the Gregorian calendar Doomsdays.


==The algorithm== ==The algorithm==
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. 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. ] is therefore part of the ], not the ].) 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. Separately, take the integral part of the quotient when the century number minus one is divided by four. Add these two numbers (the product of the multiplication and the integral of the division). Taking the remainder mod 7 is often done at this point to make the numbers more manageable, since it won't affect the result. Now count forward that number of days from ] to get the anchor day for the century. For example, the calculation for the twentieth century is: multiply the century number 20 by 5 to get 100; subtract 1 from the century number and then divide by 4 to get 4; sum 100 and 4 to get 104; find the remainder mod 7 to get 6; count 6 days on from Thursday for the answer, Wednesday. Similarly, the anchor date for the twenty-first century is Tuesday. 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. ] is therefore part of the ] in this equation, not the ].) 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 (call this ''x''). Separately, subtract one from the century number, divide by four and take the ] (the next-lowest whole number) of the ] (''y''). Add these two numbers (''x'' and ''y'' to get ''z''). (At this point a common optional step is to divide ''z'' by seven, and take the remainder so as to make the numbers more manageable, since this won't affect the result.) Now count forward that number of days (''z'' '''or''' the remainder of ''z''/7) from ] to get the anchor day for the century.<br>
For example, the calculation for the twentieth century is: multiply the century number (20) by 5 to get 100; subtract 1 from the century number and then divide by 4 to get an integral value of 4; add 100 and 4 to get 104; (optionally divide by 7 to get a remainder of 6;) count 104 (or 6) days from Thursday for the answer, Wednesday.<br>
That is: '''20''' &times; 5 = '''100'''. '''20''' &minus; 1 = '''19'''. '''19''' &divide; 4 = '''4''' R4. '''100''' + '''4''' = '''104'''. (Optional: '''104''' &divide; 7 = 14 R'''6'''.) '''104''' (or '''6''') days after Thursday is '''Wednesday'''. So Wednesday is the anchor day for the '''20'''th century.<br>
Similarly, the anchor date for the twenty-first century is Tuesday: '''21''' &times; 5 = '''105'''. '''21''' &minus; 1 = '''20'''. '''20''' ;&divide; 4 = '''5'''. '''105''' + '''5''' = '''110'''. (Optional: '''110''' &divide; 7 = 15 R'''5'''.) '''110''' (or '''5''') days after Thursday is '''Tuesday'''.


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 year's last two digits are divided by 12. Next, it is necessary to find the year's Doomsday&mdash;the day of the week on which the last day of February falls. To accomplish that according to Conway, begin by dividing the year's last two digits by 12 and taking the integral value of the quotient (''a''). Then take the remainder of the same quotient (''b''). After that, divide that remainder by 4 and take the integral value (''c''). Finally, determine the sum of the three numbers (add ''a'', ''b'', and ''c'' to get ''d''). (It is again possible here to divide by seven and take the remainder. This number is equivalent, as it must be, to the sum of the last two digits of the year plus the integral value those digits divided by four.)<br>
Now count forward the specified number of days (''d'' or the remainder of ''d''/7) from the anchor day to get the year's Doomsday.
Next, determine the remainder of this first quotient.
For the twentieth-century year 1966, for example: divide the last two digits (66) by 12 to get an integral value of 5 with a remainder of 6; divide the 6 by 4 to get an integral value of 1; add the 5, the 6, and the 1 to get 12; (optionally divide by 7 to get a remainder of 5;) count 12 (or 5) days from Wednesday (the result above for the 20th century anchor day) for a result of Monday.<br>
After that, take the integral part of this number when it is divided by 4. Finally, determine the sum of the three numbers.
As a set of equations: '''66''' &divide; 12 = '''5''' R'''6'''. '''6''' &divide; 4 = '''1''' R2. '''5''' + '''6''' + '''1''' = '''12'''. (Optional: '''12''' &divide; 7 = 1 R'''5'''.) '''12''' (or '''5''') days after Wednesday (the anchor day of the 20th century, see above) is ''Sunday''. So Doomsday in 19'''66''' fell on Monday.<br>
(This is equivalent mod 7, as it must be, to the sum of the last two digits plus those digits divided by four.)
Similarly, Doomsday in 20'''04''' was on a Sunday: ''04'' &divide; 12 = '''0''' R'''4'''. '''4''' &divide; 4 = '''1'''. '''0''' + '''4''' + '''1''' = '''5'''. (Optional: '''5''' &divide; 7 = 0 R'''5'''.) '''5''' days after Tuesday is '''Sunday'''.

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: The following days all occur on Doomsday for any given Gregorian year:
* ] (or "]", ie ], in ]) * ]st (or "]th", ie ]st, in ])
* ] (or ] if it's a leap year) * ]th (or ]th if it's a leap year)
* "]" (a backwards extension of the calendar, equivalent to the last day of February.) * "]" (a backwards extension of the calendar, equivalent to the last day of February.)
* ] * ]th
* ] * ]th
* ] * ]th
* ] * ]th
* ] * ]th
* ] * ]th
* ] * ]th
* ] * ]th
* ] * ]th
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 ]." 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 ]."


For dates in March, ] falls on Doomsday, but the pseudodate "March 0" is easier to remember, as it is necessarily the same as the last day of February. Similarly, in leap years the pseudodate "January 32" is easier to remember than ], as it is necessarily the same as ]. For dates in March, ] falls on Doomsday, but the pseudodate "March 0" is easier to remember, as it is necessarily the same as the last day of February. Similarly, in leap years the pseudodate "January 32" is easier to remember than ], as it is necessarily the same as ] (and therefor February 29th).

Therefore, if you know what day of the week Doomsday&nbsp;&mdash;the last day in February&nbsp;&mdash;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 complete list:
Therefore, if you know what day of the week Doomsday&nbsp;&mdash; the last day in February&nbsp;&mdash; 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.
*] (common years):]rd, ]th, ]th, ]th, & ]st
*] (leap years):]th, ]th, ]th, & ]th
*] (common years): ]th, ]th, ]st, & ]th
*] (leap years): ]st, ]th, ]th, ]nd, & ]th
*]: ]th, ]th, ]st, & ]th
*]: ]th, ]th, ]th, & ]th
*]: ]nd, ]th, ]th, ]rd, & ]th
*]: ]th, ]th, ]th, & ]th
*]: ]th, ]th, ]th, & ]th
*]: ]st, ]th, ]th, ]nd, & ]th
*]: ]th, ]th, ]th, & ]th
*]: ]rd, ]th, ]th, ]th, & ]st
*]: ]th, ]th, ]st, & ]th
*]: ]th, ]th, ]th, & ]th


==In code== ==In code==
Line 65: Line 83:
"anchor" is the anchor day for the century and "dday" is the doomsday for the year. "anchor" is the anchor day for the century and "dday" is the doomsday for the year.
If "dday" is found to be Monday, then January 3 (or 4th), February 28 (or 29th), March 0, April 4, May 9, etc. (see above). If "dday" is found to be Monday, then January 3 (or 4th), February 28 (or 29th), March 0, April 4, May 9, etc. (see above).
To find the day of the date in question, determine the number of days away from the doomsday for that month and add it to "dday" modulo 7. To find the day of the date in question, determine the number of days away from the doomsday (as a positive value after and a negative before) for that month and add it to "dday" modulo 7.


==Examples== ==Examples==

Revision as of 18:29, 5 September 2005

The Doomsday rule 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 was invented by John Horton Conway. It can be used for either the Gregorian Calendar A.D. or the Julian Calendar, but note that Julian calendar Doomsdays usually occur on different days from the Gregorian calendar Doomsdays.

The algorithm

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. 2000 is therefore part of the twenty-first century in this equation, 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 (call this x). Separately, subtract one from the century number, divide by four and take the integral value (the next-lowest whole number) of the quotient (y). Add these two numbers (x and y to get z). (At this point a common optional step is to divide z by seven, and take the remainder so as to make the numbers more manageable, since this won't affect the result.) Now count forward that number of days (z or the remainder of z/7) from Thursday to get the anchor day for the century.
For example, the calculation for the twentieth century is: multiply the century number (20) by 5 to get 100; subtract 1 from the century number and then divide by 4 to get an integral value of 4; add 100 and 4 to get 104; (optionally divide by 7 to get a remainder of 6;) count 104 (or 6) days from Thursday for the answer, Wednesday.
That is: 20 × 5 = 100. 20 − 1 = 19. 19 ÷ 4 = 4 R4. 100 + 4 = 104. (Optional: 104 ÷ 7 = 14 R6.) 104 (or 6) days after Thursday is Wednesday. So Wednesday is the anchor day for the 20th century.
Similarly, the anchor date for the twenty-first century is Tuesday: 21 × 5 = 105. 21 − 1 = 20. 20 ;÷ 4 = 5. 105 + 5 = 110. (Optional: 110 ÷ 7 = 15 R5.) 110 (or 5) days after Thursday is Tuesday.

Next, it is necessary to find the year's Doomsday—the day of the week on which the last day of February falls. To accomplish that according to Conway, begin by dividing the year's last two digits by 12 and taking the integral value of the quotient (a). Then take the remainder of the same quotient (b). After that, divide that remainder by 4 and take the integral value (c). Finally, determine the sum of the three numbers (add a, b, and c to get d). (It is again possible here to divide by seven and take the remainder. This number is equivalent, as it must be, to the sum of the last two digits of the year plus the integral value those digits divided by four.)
Now count forward the specified number of days (d or the remainder of d/7) from the anchor day to get the year's Doomsday. For the twentieth-century year 1966, for example: divide the last two digits (66) by 12 to get an integral value of 5 with a remainder of 6; divide the 6 by 4 to get an integral value of 1; add the 5, the 6, and the 1 to get 12; (optionally divide by 7 to get a remainder of 5;) count 12 (or 5) days from Wednesday (the result above for the 20th century anchor day) for a result of Monday.
As a set of equations: 66 ÷ 12 = 5 R6. 6 ÷ 4 = 1 R2. 5 + 6 + 1 = 12. (Optional: 12 ÷ 7 = 1 R5.) 12 (or 5) days after Wednesday (the anchor day of the 20th century, see above) is Sunday. So Doomsday in 1966 fell on Monday.
Similarly, Doomsday in 2004 was on a Sunday: 04 ÷ 12 = 0 R4. 4 ÷ 4 = 1. 0 + 4 + 1 = 5. (Optional: 5 ÷ 7 = 0 R5.) 5 days after Tuesday is Sunday.

The following days all occur on Doomsday for any given Gregorian year:

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. Similarly, in leap years the pseudodate "January 32" is easier to remember than January 4, as it is necessarily the same as February 1 (and therefor February 29th).

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 complete list:

In code

The following is the algorithm in C. Please note that division in C (using the / operator) is integer division and that the % operator is the modulo operator.

Set "year" to whatever year (this case is 2005) computation is desired and the numeric values of the days of the week are:

0 – Sunday
1 – Monday
2 – Tuesday
3 – Wednesday
4 – Thursday
5 – Friday
6 – Saturday
// Determine the anchor day for the century
year    = 2005;
century = year/100 + 1;
a       = century * 5;
b       = (century - 1) / 4;
c       = a + b;
anchor  = (c + 4) % 7;
// Determine the Doomsday for the year in question
e       = (year % 100)/12;
f       = (year % 100)%12;
g       = f/4;
h       = e + f + g;
dday    = (h + anchor) % 7;

"anchor" is the anchor day for the century and "dday" is the doomsday for the year. If "dday" is found to be Monday, then January 3 (or 4th), February 28 (or 29th), March 0, April 4, May 9, etc. (see above). To find the day of the date in question, determine the number of days away from the doomsday (as a positive value after and a negative before) for that month and add it to "dday" modulo 7.

Examples

Example 1 (this year)

Suppose you want to know which day of the week Christmas Day of 2005 is. In the year 2005, Doomsday is Monday. (The century's anchor day is 110 days after Thursday, or Tuesday, and 2005's Doomsday is six days beyond.) This means that December 12 is a Monday. December 25, being thirteen days afterwards, falls on a Sunday.

Example 2 (other years of this century)

Suppose that you want to find the day of week that the September 11, 2001 attacks on the World Trade Center occurred. The anchor is Tuesday, and one day beyond is Wednesday. September 5 is a Doomsday, and September 11, six days later, falls on a Tuesday.

Example 3 (other centuries)

Suppose that you want to find the day of week that the American Civil War broke out at Fort Sumter, which was April 12, 1861. The anchor day is 99 days after Thursday, or Friday. The digits 61 give a displacement of six days, so Doomsday was Thursday. Therefore, April 4 was Thursday, so April 12, eight days later, is a Friday.

External links

Categories: