Easter calculations
Sep. 5th, 2012 09:12 pmStruggling to keep track of the count of the endless Sundays after Trinity, I became curious about the method used to calculate the date of Easter. This in turn led to to a Metonic cycles, a whole load of clever Medieval attempts to nail down the correct date, and eventually to a handful of lines of python:
from datetime import datetime
def easter(year):
year = int(year)
a = year % 19
b, c = divmod(year, 100)
d, e = divmod(b, 4)
f, r = divmod(b + 8, 25)
g, r = divmod((b - f) + 1, 3)
h = ((19 * a) + (b - d - g) + 15) % 30
i, k = divmod(c, 4)
L = (32 + (2 * e) + ((2 * i) - h - k)) % 7
m, r = divmod(a + (11 * h) + (22 * L), 451)
month, day = divmod((h + L) - (7 * m) + 114, 31)
day += 1
return datetime(year, month, day)
Because once you know the date of Easter, the remaining moveable feasts are almost easy to work out...