Perpetual Calendar – Weekday computation in your head

To compute the (Gregorian calendar's) weekday for any date, all you need are the following formula and table:


( DayOfMonth + MonthCode + Year + Year/4 – 2×(Century%4) – isLeapJanFeb ) % 7

Mon 0 Aug
Tue 1 Feb, Mar, Nov
Wed 2 Jun
Thu 3 Sep, Dec
Fri 4 Apr, Jul
Sat 5 Jan, Oct
Sun 6 May

If you care to memorize this, you might prefer the following table for the months:

JFMAMJJASOND
511462403513

In the formula,

In order to find the weekday, the resulting number only needs to be looked up in the table already used for the months. You can check the result using this form:

Example: 8 May 1945

(DayOfMonth+MonthCode+Year+Year/42×(Century%4)isLeapJanFeb) % 7
(8+6+45+45/42×(19%4)0) % 7
(8+6+45+112×30) % 7=64 % 7=1
So the official end of World War II in Europe was a Tuesday. You might check for yourself that it began (1 Sep 1939) on a Friday. Unfortunately with not just one, but 297 weekends in between...

Julian Calendar

In this calendar, not only are leap years simply defined as all those that are a multiple of 4, but the formula also differs slightly:
( DayOfMonth + MonthCode + Year + Year/4 + 5 – Century – isLeapJanFeb ) % 7
Example: 24 Aug 0079, the day Pompeii was buried by Mt. Vesuvius' eruption, was a Tuesday [(24+0+79+19+5–0–0)%7=1]. In the Gregorian calendar, it would have been 22 Aug 0079 (how to compute this is a different story), which unsurprisingly was a Tuesday as well [(22+0+79+19–0–0)%7=1]: When switching from Julian to Gregorian because the former was getting out of sync with the seasons, there was no need to additionally interrupt the cycle of weekdays.