There are many ways to do this, and the one given is one I really dislike. A lot.<p>Here's the one I use.<p><pre><code> 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.
</code></pre>
So Dec 25th, 2013 is given by (1 + 6 + 25) % 7 = Wednesday.<p>An adjust is required for dates in January or February in leap years.<p>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.<p>[0] <a href="http://en.wikipedia.org/wiki/Doomsday_rule" rel="nofollow">http://en.wikipedia.org/wiki/Doomsday_rule</a><p>[1] <a href="http://www.timeanddate.com/date/doomsday-weekday.html" rel="nofollow">http://www.timeanddate.com/date/doomsday-weekday.html</a>