Doomsday rule: Difference between revisions
Content added Content deleted
Line 84: | Line 84: | ||
# Conway's doomsday algorithm |
# Conway's doomsday algorithm |
||
c, r = divrem(year, 100) |
c, r = divrem(year, 100) |
||
s, t = divrem(r, 12) |
|||
canchor = (5 * (c % 4) + 2) % 7 # anchor for century |
|||
canchor = (5 * (c % 4) + 2) % 7 # anchor for centiry |
|||
doomsday = (s + t + (t ÷ 4) + canchor) % 7 |
|||
anchorday = (year % 4 != 0) || (r == 0 && year % 400 == 0) ? # leap year determination |
anchorday = (year % 4 != 0) || (r == 0 && year % 400 == 0) ? # leap year determination |
||
nonleapyear_firstdoomsdays[month] : leapyear_firstdoomsdays[month] |
nonleapyear_firstdoomsdays[month] : leapyear_firstdoomsdays[month] |