Comment

Comment by ColinWright

This is very similar to the method I use and, after conversation with him, the method Art Benjamin uses. It's trivial to do in 10 to 15 seconds, though it requires practice, a very small amount of memorisation[0], and a small amount of mental arithmetic. I use it regularly, partly to keep in practice, and partly because once you have the skill you find it's surprisingly useful.

JH Conway used a different technique[1] which I have swutch to when computing days in the current year. It's quicker and easier, but I find that it's harder to compute "The Doomsday" for other years (it's Thursday this year), so I revert to my standard method[2].

Example: Today is 2024/05/24

    Years since 2012 is 12
    Leap years is 12/4 = 3
    Magic month number = 2
    Date is 24
    Add mod 7 is (12+3+2+24) = (-2)+3+2+3 = 6 = Friday
[0] A "magic number" for each month. There are mnemonics, and they can be computed from first principles if needed. It's also easy to remember a few and then compute the others.

  144 : Jan, Feb, Mar
  025 : Apr, May, Jun
  036 : Jul, Aug, Sep
  146 : Oct, Nov, Dec
[1] https://en.wikipedia.org/wiki/Doomsday_rule

[2] All values computed mod 7. Take years since 1900. Add number of leap years since 1900 (so (YYYY-1900)/4 rounded down). Add the magic number for the month. Add the day of the month. Then Sunday=1, Wednesday=4, etc.

Because the calendar repeats every 28 years, for more recent dates you can start with 2012 instead of 1900.

parent ColinWright 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton