Sep. 5th, 2012

sawyl: (Default)
Struggling 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...

Profile

sawyl: (Default)
sawyl

August 2018

S M T W T F S
   123 4
5 6 7 8910 11
12131415161718
192021222324 25
262728293031 

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 4th, 2026 02:51 pm
Powered by Dreamwidth Studios