Doomsday Algorithm
Main Concept

Have you ever wondered what day of the week a particular date fell on? What would you do if you didn't have access to a calendar? The Doomsday Algorithm is a method developed by John Conway to find the day of the week of any given date based on a perpetual calendar. In any given year, there are certain easytoremember 'special' dates that all happen to occur on the same day of the week. That day of the week is called the doomsday for that year, and the corresponding dates are called special doomsday dates. The doomsday can be easily calculated starting from the given year. Then you can simply compare the current date with the nearest (or any) 'special' date to determine the current day of the week:
1.

Find the doomsday of the year using the doomsday algorithm. This involves first finding an anchor day for the century, then using the last two digits of the century to find the number of days ($x$) that the anchor day must be shifted by to determine the doomsday for the year.

2.

Find the closest special doomsday date, one of a number of easy to remember dates that falls on the doomsday of the year.

3.

Figure out the shift between the current date and the closest special date, then apply that same shift to the doomsday to find the current day of the week.




From this point on, the days of the week will be used interchangeably with the integers modulo 7 using the following table:
Sunday

Monday

Tuesday

Wednesday

Thursday

Friday

Saturday

0

1

2

3

4

5

6




Finding the Anchor Day of the Century


The Gregorian Calendar, also the internationally accepted calendar of today, has the following scheme:
•

The cycle of the calendar repeats itself every 400 years.

•

A $\mathrm{common}$ year consists of 365 days, while a $\mathrm{leap}$ year consists of 366 days (the $\mathrm{leap}$ day or added day being February 29).

•

A $\mathrm{leap}$ year occurs every year denoted by a multiple of four, except for multiples of 100 that are not multiples of 400. For example, the years 1700, 1800 and 1900 are not leap years, while the year 2000, the fourth centennial in the series, is a leap year. Therefore, in a Gregorian cycle, or 400 years, there are 303 common years and 97 leap years. This is to accommodate for the fact that a solar year is slightly shorter than 365.25 days, it is 365.2425 days.

Taking all of the above into account, the anchor day for a given year is defined as:
$\mathrm{Anchor}equals;5\cdot \left(\mathrm{floor}\left(\frac{\mathrm{year}}{100}\right)\mathbf{mod}4\right)plus;\mathrm{Tuesday}$
Note: The $\mathrm{floor}$ of a number $z$, also denoted $\mathbf{}\u230az\u230b$, is the greatest integer smaller than $z$. In other words, the $\mathrm{floor}$ function rounds a number down to the preceding integer.





Finding the Doomsday of the Year


There are multiple methods to finding the doomsday of a year. All three methods mentioned use the common variables:
•

Let $y$ represent the last two digits, taken collectively, of the given year's date.

•

Let $x$ be the number of days to be added to the anchor day, between the anchor day and the doomsday.


Method 1
1.

Add $y$ to integer quotient, or floor, of $y$ divided by 4.

2.

Divide the sum by 7, $a$ is the remainder of this process.

$xequals;\left(yplus;\u230a\frac{y}{4}\u230b\right)\mathbf{mod}7$

Method 2
1. Let $a$ to be the floor of $\frac{y}{12}$.
2. Let $b$ to be the modulus of $\frac{y}{12}$.
3. Let $c$ be the floor of $\frac{b}{4}$.
4. $x$ is the modulus of $\frac{aplus;bplus;c}{7}$.
$aequals;\u230a\frac{y}{12}\u230bsemi;\phantom{\rule[0.0ex]{0.0em}{0.0ex}}bequals;y\mathbf{mod}12semi;\phantom{\rule[0.0ex]{0.0em}{0.0ex}}cequals;b\mathbf{mod}4\phantom{\rule[0.0ex]{0.0em}{0.0ex}}\phantom{\rule[0.0ex]{0.0em}{0.0ex}}\phantom{\rule[0.0ex]{0.0em}{0.0ex}}$$xequals;\left(\u230a\frac{y}{12}\u230bplus;y\mathbf{mod}12plus;\u230a\frac{y\mathbf{mod}12}{4}\u230b\right)\mathbf{mod}7\phantom{\rule[0.0ex]{0.0em}{0.0ex}}equals;\left(aplus;bplus;c\right)\mathbf{mod}7$

Method 3
1. Let $xequals;y$.
2. If $x$ is odd, add $11$ to it.
3. Divide $x$ by $2$.
4. If $x$ is odd again, add $11$ to it.
5. Subtract the modulus of $x$ by $7$ from $7$.
$xequals;\left(\frac{yplus;11\left(y\mathbf{mod}2\right)}{2}plus;11\left(\frac{yplus;11\left(y\mathbf{mod}2\right)}{2}\right)\mathbf{mod}2\right)\mathbf{mod}7$

Shift the anchor day by $x$ to obtain the doomsday.





Finding the Closest Special Doomsday Date to the Given Date


The following is a table of special doomsday dates for any given year, along with a simple mnemonic for remembering them. The current step involves just choosing one of these that is relatively close to the given date.

Special Doomsday Dates



Date(s)

Mnemonic



4/4, 6/6, 8/8, 10/10, 12/12

Dates in the form n/n, where n is an even number between 4 and 12



5/9, 9/5, 7/11, 11/7

"I work from 9 to 5 at 711"



Feb 28/29 or 'March 0'

Last Day of February



March 14

Pi Day



October 31

Halloween






Finding the Day of the Given Date


The day of the given date is determined by simply adding to the year's doomsday, the same shift that separates the current date and one of the special doomsday dates in the above table.

Explore by entering different dates and choosing from the various algorithms.
Month

Day

Year






Anchor Day :
Doomsday :
Actual Date :






