exupero's blog
RSSApps

Doomsdays

I've occasionally used the doomsday algorithm to calculate the day of the week for a given date without referencing a calendar. It's mostly a party trick, though I do tend to check dates in stories. As my kids approach the mathematical proficiency needed to execute the algorithm, I've been thinking about how to break it down for them and teach it in chunks. Here's what I have so far.

Performing the doomsday algorithm requires three steps:

  1. Memorizing which days of the year fall on the doomsday.
  2. Calculating which day of the week doomsdays fall on for a given year.
  3. Comparing dates to determine which day of the week the given date falls on.

I've listed these in order of "cacheability". You only have to memorize the dates that fall on doomsday once, and for dates in the current year (the most common use case) you can usually remember which day doomsdays fall on for the year without calculating it. For 2022, doomsdays fall on Monday.

Here's a calendar showing easy-to-remember dates that fall on Monday:

1/31/312/284/45/96/67/47/118/89/510/1011/712/12

January 3 usually, January 4 on leap years. After February, reference dates don't change on leap years.


January 31 usually, February 1 on leap years. It's useful to think of January 31 as February 0.


February 28 usually, February 29 on leap years. As before, it's helpful to think of the last day of February as March 0.



April 4, June 6, August 8, October 10, December 12. Even-numbered months after February are the easiest to remember the reference dates for, since the date matching the month number falls on doomsday: 4/4, 6/6, 8/8, 10/10, 12/12.

May 9 and September 5. These are mirror images of each other, easily remembered by the standard working hours of 9 to 5: 5/9 and 9/5.




July 4. In the United States, Independence Day falls on a doomsday.

July 11 and November 7. Like the reference dates for May and September, these are mirror images of each other, easily remembered by the convenience store 7-Eleven: 7/11 and 11/7.



We'll see in a later post why we need one reference date a month, and the earlier in the month the better.

The reason reference dates before March change between leap years and non-leap years is because the math counts January and February as the 13th and 14th months of the previous year. That provides an additional reference date for February on non-leap years, one that follows the pattern of other even-numbered months: the 14th.

In the next post, I'll walk through calculating the anchor day for an arbitrary year.