Logo
Color-Of-Code
  Home   All tags   Terms and Conditions

Doomsday rule

March 17, 2020

Doomsday rule

It takes advantage of each year having a certain day of the week, called the doomsday, upon which certain easy-to-remember dates fall; for example, 4/4, 6/6, 8/8, 10/10, 12/12, and the last day of February all occur on the same day of the week in any year.

Prerequisites

Remembering the day numbers

Day of weekNumberMnemonic
Sunday0Noneday or Sansday
Monday1Oneday
Tuesday2Twosday
Wednesday3Treblesday
Thursday4Foursday
Friday5Fiveday
Saturday6Six-a-day

Depending on the method other values can be used. These are used here consistently.

Remembering the month numbers

MonthNumber
January1
February2
March3
April4
May5
June6
July7
August8
September9
October10
November11
December12

Leap year

  • divisible by 4 -> leap
  • but excepted centuries -> not leap
  • but centuries divisible by 4 -> leap (e.g. 1600, 2000)

Dates landing on Doomsday

  • Mnemonic 1: "the 3rd during 3 years in 4, and the 4th in the 4th year"
  • Mnemonic 2: "last day of February"
  • Mnemonic 3: "I work from 9 to 5 at the 7-11"
  • Mnemonic 4: "4/4, 6/6, 8/8, 10/10, 12/12"
MonthMemorable dateMnemonicAll days
January01-03 (common years)13, 10, 17, 24, 31
January01-04 (leap years)14, 11, 18, 25
February02-28 (common years)20, 7, 14, 21, 28
February02-29 (leap years)21, 8, 15, 22, 29
March03-0020, 7, 14, 21, 28
April04-0444, 11, 18, 25
May05-0932, 9, 16, 23, 30
June06-0646, 13, 20, 27
July07-1134, 11, 18, 25
August08-0841, 8, 15, 22, 29
September09-0535, 12, 19, 26
October10-1043, 10, 17, 24, 31
November11-0730, 7, 14, 21, 28
December12-1245, 12, 19, 26

Steps

Example:

$Date:2020-03-17$

$Century = 2020/100 = 20$

1 - anchor day for the century

Formula:

$Anchor = 5 * (Century \mod 4) \mod 7 + 2$

Example:

$Anchor = 5 * (20 \mod 4) \mod 7 + 2 = 2 = Tuesday$

2 - doomsday for the year

Method for finding the year's doomsday was discovered in 2010 by Chamberlain Fong and Michael K. Walters and described in their paper submitted to the 7th International Congress on Industrial and Applied Mathematics (2011). Called the "odd + 11" method, it is equivalent to computing:

$\left(y + \left\lfloor \frac{y}{4} \right\rfloor\right) \bmod 7$

Mnemonic: repeated use of the "odd + 11" rule.

Extending this to get the doomsday, the procedure is often described as accumulating a running total T in six steps, as follows:

  • Let $T$ be the year's last two digits.
  • If $T$ is odd, add 11.
  • Now let $T = T/2$.
  • If $T$ is odd, add 11.
  • Now let $T = 7 − (T \bmod 7)$.
  • $Doomsday = T + Anchor$

Example 2005:

  • $T = 5$
  • $T = 5 + 11 (odd) = 16$
  • $T = 16/2 = 8$
  • $T = 8 (even)$
  • $T = 7 − (8 \bmod 7) = 7 − 1 = 6$
  • $Doomsday = (6 + 2) \bmod 7 = 1 = Monday$

Example 2020:

  • $T = 20$
  • $T = 20 (even)$
  • $T = 20/2 = 10$
  • $T = 10 (even)$
  • $T = 7 − (10 \bmod 7) = 7 − 3 = 4$
  • $Doomsday = (4 + 2) \bmod 7 = 6 = Saturday$

3 - day of week from nearest doomsday

Find the nearest doomsday and count days.

$((Day - NearestDoomsday) \bmod 7 + Doomsday) \bmod 7$

Example:

$2020-03-17$

  • $NearestDoomsday = 03-14 = 14$,
  • $Doomsday(2020) = 6$
  • $DayOfWeek = ((17-14) \bmod 7 + 6) \bmod 7 = 9 \bmod 7 = 2 = Tuesday$