Doomsday Protocol — A Review
Motivation^{1}
As Gregor Samsa awoke one morning from uneasy dreams he found himself stuck within a barren wasteland. Apparently, he has time travelled to the year 2637, and the day was March 14. The marvellous infrastructure that was once human civilization has been flattened and the Earth reduced to an inhospitable toxic wasteland five centuries prior when a nuclear war broke out between powerful and uncompromising nations.
Being Gregor Samsa, he needs to figure out what day of the week it is so as to determine his work schedule. However, our friend is in a bit of a plight here. All electronic devices are gone, and any calendar that might have the year 2637 on it for whatever reason has also decayed over the past few hundred years.
Gregor remembers that “yesterday,” September 28, 1908 was a Monday. He could count his way up to the current day, but that would definitely take too long, and he would be late for his nonexistent train should it happen to be a weekday, god forbid. Moreover, Gregor didn’t pay attention in school when his math teacher went off on a tangent about the genius behind the Gregorian calendar system. Austria had adopted this more accurate system in 1583, long before Gregor was born.^{2} At least Gregor wouldn’t have to remember that the October revolution happened in November.
Calendar Systems 101
Since Gregor didn’t pay attention in school when his math teacher ranted about the Gregorian calendar (despite the similarities between their names), Gregor probably doesn’t remember how leap years work in Gregorian either. Here’s a recap:
Here’s a quantity that will become important: a tropical year is approximately 365.24219 days long.^{3} Clearly, having 365 days in a year is a little bit too short, and 366 days a little bit too long. These errors add up over time and mess up our calendar, shifting seasons and causing unintended consequences. Therefore, a fix is needed. We could first try to use a combination of 365dayyears and 366dayyears to even out the error, which is exactly what both calendars do.
 For both Julian and Gregorian calendars, every four years (at exact multiples of 4, such as 2000, 2004, 2008, etc.) a leap day is inserted as February 29 making the year a leap year.
 This results in the average year being $ 365 + 1/4 = 365.25 $ days long, which is a slight overshot, although already much better than before. However, as we know, the Gregorian calendar continues to make optimizations.
 In the Gregorian calendar, every hundredth year (or every 25th leap year) the leap day is removed, making years such as 2000, 2100, 2200, and so on no longer leap years.
 With this tweak, the average year is now $ 365 + 1/4  1/100 = 365.24 $ days long. But now, we are on average underestimating the length of the year. So, logically, we would have to add some back.
 In the Gregorian calendar, every four hundredth year, the leap day is once again added back, making years such as 1600, 2000, and 2400, which were previously stripped of their leap days, leap years once again after returning their leap days.
 Finally, the average year is now $ 365 + 1/4  1/100 + 1/400 = 365.2425 $ days long.
Is That Accurate Enough?
For the purposes of a functional society, this level of precision is acceptable, as we won’t have to deal with any significant shifting for the forseeable future. Moreover, at larger time scales, Earth’s speed of rotation on its own axis (i.e. the length of a day) changes as well, so we’ll just have to see in a myriad years what to change about the Gregorian system. Hopefully, by then, they would have gotten rid of weekdays and just given us weekends every day instead.^{4}
Something Crazy to Ponder
Matt Parker’s Standup Maths channel has a video on YouTube that presented a leap year system deriving from the binary representation of each year and is more accurate (although less practical) than the Gregorian calendar.
Gregor’s Solution: The Doomsday Protocol
Since we learned that the Gregorian calendar follows a small set of rules strictly, we could try to come up with a formula that allows us to find the weekday given any date (YYYYMMDD). The solution we get is oftentimes known as the Doomsday Protocol, a fitting name. First, notice that between centures (e.g. between 1900 and 2000, or between 2600 and 2700), none of the years in between are multiples of 100. For convenience, let’s associate each weekday with a number in $ \mathbb{Z}/7\mathbb{Z} $ (the integers modulo 7).
Weekday  Number 

Sunday  0 
Monday  1 
Tuesday  2 
Wednesday  3 
Thursday  4 
Friday  5 
Saturday  6 
Notice that all the weekdays are just assigned to their intuitive value except Sunday is assigned to 0. Hopefully, this also satisfies those who feel strongly about Sunday being the first day of the week. Now, we should take note that $ 365 % 7 = 1 % and $ 366 % 7 = 2 % (364 is a multiple of 7). This means that each normal year, the weekdays slide over by 1, and each leap year the weekdays slide over by 2.
So, for example, if March 14th, 2008 was on a Friday (which it is), then March 14th, 2009 would be on a Saturday. Whereas if March 14th, 2003 was on a Friday, then March 14th, 2004 would be on a Sunday. Note that in the first case no leap days passed in bewteen the two dates, whereas in the second case there was the date February 29, 2004. Summarizing this idea, once we know the weekday of a particular day of a year, then we can deduce the weekday of that same day of a different year by counting the years elapsed, then counting the number of leap days elapsed, summing them and taking them to modulo 7 (the remainder when they are divided by 7). Generally, since we start from centuries and end on the next, our year code would be
\[X + \left\lfloor \frac{X}{4} \right\rfloor\]Here I would like to make the disclaimer that this post isn’t really meant to teach the Doomsday protocol. Rather, I am just replicating the method I learned and bringing light to some of its methodologies or justification.
As for the centuries (first two digits), you will have to add a century code to your calculation to account for initial offset. These are trickier to calculate, but they repeat every four years, so they are probably worth memorizing. These codes, also known as anchors, are summarized in the table below.
Centuries  Anchor Code 

…,1600,2000,2400,…  2 
…,1700,2100,2500,…  0 
…,1800,2200,2600,…  5 
…,1900,2300,2700,…  3 
The Easy Dates Method
This was the method that I first learned many years ago (and still remember to this day). At this point, most methods are just about how much you memorize and how much you calculate. Much like designing algorithms for machines to run, human calculation methods often see a tradeoff between memorization and speeddelay from realtime calculation. This method definitely belongs on the lighterweight side.
Once we have the weekday of a specific date of the prevalent year, we could shift around to find other dates.^{5} However, shifting across one or more months is highly prone to error. Hence, if we could remember a day of each month whose weekday is equivalent to the code we obtain from calculating the anchor code and years formula. This method does exactly that: giving us twelve relatively easy days to remember as they are related to one another. These are the dates circled in the above calendar. Notice that they all land under Monday (1), and the year 2022 corresponds to the code 2 + 22 + 22//4 = 2 + 22 + 5 = 29 = 1 (mod 7)
–this adds up!
Important “Doomsdays”:
 January and February: both on the last day of the month.
 March: Pi day: on the 14th.
 Even months, April through December: Amazingly, 4/4, 6/6, 8/8, 10/10, and 12/12 all satisfy our requirement.
 Remaining odd months: split into two pairs: 9/5 and 5/9, then 11/7 and 7/11.^{6}
Don’t forget: when we are computing a date in January or February of a leap year, we always have to subtract the extra leap day we added as it has not happened yet!
The More Efficient Method
Of course, my research would lead me to more efficient methods that hobbyists and professional memorysport athletes have devised over the years. I have to note that there are many similar if not equivalent systems out on the internet, since the choices we make and dates we set to be our “anchors” in general are arbitrary (we only choose those that seem easy to remember).
I’ve found that most efficient methods, in the interest of time, replaced the datefinding system I presented above with another series of “month codes” for the user to memorize. Once these codes have been memorized, the doomsday protocol could be reasonably computed for most dates within 5 seconds. Here is the list of month codes:
Month  Anchor Code 

January  4 
February  0 
March  0 
April  3 
May  5 
June  1 
July  3 
August  6 
September  2 
October  4 
November  0 
December  2 
Just as in the case with century anchor codes, where we needed to somehow memorize 2053
, for these codes we just have to memorize 400351362402
. I prefer doing this by splitting them into threes; however I don’t really have a mnemonic method. If you use one, you might have to account for that as well. As long as you can recall these values on demand, then you are all set!
A Demonstration and Verbatim
Now, Gregor is prepared to discover the answer his longawaited query. He checks that the century 2600 has the anchor code 5, and that the number of leap days passed since 2600 is 37//4 = 9
. Doing a bit of simplification as we add these numbers, we find that
5 + 34 + 9 = 5  1 + 2 = 6 (mod 7)
It just so happens that Gregor’s current date is Pi day, one of our Doomsdays from the Easy Dates Method. Hence, we get the answer that March 14, 2637 is a Saturday, and poor Mr. Samsa finally gets a break, although there isn’t much to do outside.
Note that the Easy Dates Method could be inefficient when the date given is far away from the Doomsday of that month. Using the monthanchored method, which is usually faster, we take the month anchor 0 and date 14 to directly obtain the answer:
5 + 34 + 9 + 0 + 14 = 5  1 + 2 = 6 (mod 7)
And voilà, there we have it!
Update: A friend of mine recently learned this method and remarked that she could not stop calculating weekdays while working on her urgent history essay. If the same is happening for you, my advice would be to just calculate all the weekdays and then write them down next to the dates so you won’t feel tempted to calculate them again. Also, always ask yourself whether you’re sure that this date is in the Gregorian calendar before applying the formula.
Footnotes:

If needed! ↩

See here. Although The Metamorphosis does not reveal a geographic location, we will assume for the purpose of this lighthearted article that it takes place in the country of Kafka’s residence, Austria. ↩

A tropical year corresponds to the cycles of seasons. This measurement of 365.24219 (which I memorized years ago for fun but never found the source) was the length of the year 2000 (source). ↩

The Gregorian calendar is off by about 27 seconds each year, or it counts an extra day each 3236 years (source). ↩

An interesting fact to note is that the dates I wrote above are all “Americanfriendly,” meaning that they have a certain degree of symmetry that an American reading the text will interpret roughly the same information as would a normal person. ↩