

Mental math - Find the day of the week a given date falls on - exupero
http://spin.atomicobject.com/2013/11/03/day-of-week/

======
ColinWright
There are many ways to do this, and the one given is one I really dislike. A
lot.

Here's the one I use.

    
    
        Each year has a magic number.  For 2013 it's 1.
        You can compute the magic number for the year.
    
            Subtract 1900 (or 2012).
            Divide by four, round down, and add it on.
            The magic number is (Y + Y/4) % 7
    
        Each year has a magic number:
    
            1 4 4 (so January is 1)
            0 2 5
            0 3 6 (so August is 3)
            1 4 6 (so November is 4)
    
        You can compute these, but I don't recommend it.
    
        Add these two magic numbers, the day of the month,
        and compute the remainder mod 7.  Then
    
            Sunday = 1
            Wednesday = 4
    
        etc.
    

So Dec 25th, 2013 is given by (1 + 6 + 25) % 7 = Wednesday.

An adjust is required for dates in January or February in leap years.

Conway's "Doomsday Algorithm"[0][1] is an alternative, and while Art Benjamin
uses the same technique I do, he teaches a variant that he claims is easier to
remember.

[0]
[http://en.wikipedia.org/wiki/Doomsday_rule](http://en.wikipedia.org/wiki/Doomsday_rule)

[1] [http://www.timeanddate.com/date/doomsday-
weekday.html](http://www.timeanddate.com/date/doomsday-weekday.html)

