sawyl: (Default)
[personal profile] sawyl
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...

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

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

Style Credit

Expand Cut Tags

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