Michael Keith (the individual responsible for
Keith Numbers,
chessametics and the 3835
digit pi mnemonic,
Cadaeic Cadenza) also brings us the world's most
concise C function to calculate the
day of the week (at 45 characters in length):
1
d: day (d=1..31)
m: month (m=1..12)
Y: year
D: day of the week (0=Sunday, 1=Monday, ... 6=Saturday)
D = (d+=m<3?y--:y-2,23*m/9+d+4+y/4-y/100+y/400)%7;
1 Michael Keith points out his
function is similar
in spirit to
Zeller's Congruence.