What is this?

This is a tool I started to build in 2020 when I was learning to figure out the day-of-week of any arbitrary date in my head. The method to do so is John Conaway's doomsday algorithm.

I made this tool to quickly get random dates to practice with and check their results after working out the day-of-week in my head. I was also just starting to learn JavaScript at a deeper level and found this to be the perfect opportunity to do so. Over time I added some more features that I found useful.

These days I've moved on to other projects but will update small things here and there whenever I feel like it.

Generator

Generates random dates between the two years entered below. Default range is the past 400 years in order to make use of all century codes.

Generate   dates between years
 and 


Calculator

Calculates the day of the week of any date entered and breaks down the calculations.






Last-Two-Digits Offset

Add the number of leap years (year / 4) to the year and subtract all factors of 7 from the sum. Use this tool to double check your math.

To simplify the math for larger years, you can subtract all factors of 28, (28, 56 or 84) and use that as the year instead.




Year Search

Gives a list of years in which the given date falls on the given day of week. For example, given Tuesday, January 9, this tool will guess the year 2024.


Tutorial

This is an explanation of my method to mentally compute the day-of-week of a calendar date, adapted from John Conaway's doomsday algorithm.

The day of the week is determined by adding three components: one for the day, two for the year (the first two digits, or century, and last two digits). July 20, 1969 will be used as an example.

a) Day offset
b) Century offset
c) LTD offset

Day offset:

In every year, there are certain days in each month that fall on the same day of the week of a given year. Some are very easy to remember, such as

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

There are some more that can be remembered with the mnemonic "I work 9 to 5 at the 7 eleven":

5/9 and 9/5
7/11 and 11/7

This covers most months except the first three of the year. March's doomsday is on pi day (the 14th, 3.14) February's is on the last day of the month (the 29th on leap years and the 28th on regular years), and January's is on the 3rd on regular years and the 4th on leap years. The final list of doomsdays for the year are as follows:
Jan 3 Feb 28 (Jan 4, Feb 29 on leap years)
Mar 14 Apr 4
May 9 Jun 6
Jul 11 Aug 8
Sep 5 Oct 10
Nov 7 Dec 12


Century offset:

This is the easiest part. The Gregorian calendar repeats every 400 years, so there are only 4 century codes to memorize:

1. 1700 = 0
2. 1800 = 5
3. 1900 = 3
4. 2000 = 2

After 2000 the cycle repeats, the 2100s have the century code 0, the 2200s are 5, the 2300s are 3 and so on. Same applies in reverse; the 1600s are 2 and the 1500s are 3.
Since 1969 is in the 1900s the century offset is 3.


LTD offset:

The LTD (Last Two Digits) offset is determined using the last two digits of the year, as the name suggests. You determine the offset by adding the number of leaps years for the number of years of the last two digits (LTD / 4), and subtract all factors of 7 (modulus). So for example if the LTD were '09, you would add the 2 leap years that take place in 9 years (9 / 4 = 2), and modulo the result of 11 by 7, leaving 4.

For larger years such as our example '69, there is a shortcut. The calendar repeats every 28 years within the same century, so you can modulo the year by 28, which means either subtracting 28, 56 or 84, and use that number instead as the year. So for '69 we subtract 56 and use '13 as the year for calculations instead. Then you add the leap years (3 in this case) and modulo by 7 as usual. (13 + 3 = 16, 16 % 7 = 2). Now you know the LTD offset for '13 is 2, and is the same for '69.


Putting it all together:

Now that we have determined the Day offset, Century offset, LTD offset, and all you have to do is add them and modulo the result by 7. for July 20, 1969 we got 2 as the day offset, 3 for the century and 2 for the LTD. Adding 2+3+2 we get 7, and by taking the modulus of 7 we get 0, so July 20, 1969 is Sunday according to the day codes below:

0 = Sunday
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
6 = Saturday