As I mentioned in my previous post, ‘computus‘ is the name given to the calculation of the date of Easter. What I didn’t get into was how to calculate it. There are dozens of algorithms for doing this but I’ve chosen the one from ‘Mapping Time’ by E.G.Richards. I like this one as it is relatively simple and it delivers a date in the Gregorian calendar.
var a = Math.floor(year / 100)
var b = a - Math.floor(a / 4)
var c = year % 19
var d = (15 + 19*c + b - Math.floor((a + 1 - Math.floor((a+8) / 25)) / 3)) % 30
var e = d - Math.floor((c+11*d) / 319)
var s = 22 + e + (140004 - (year + Math.floor(year / 4))%7 + b - e) % 7
var easter = new Date( year, 2, s, 0, 0, 0, 0 )
The mechanics of the algorithm are fairly arcane and I won’t be going into them in this post but if you really want to know about epacts, Golden numbers, and Dominical letters then the Wikipedia entry on computus is very good.
I looked at quite a few Easter algorithms before settling on this one. The simplest ones always delivered a date in the Julian Calendar; the reason for this being that the Julian leap year rule is much simpler than the Gregorian. This is fine but the conversion from Julian to Gregorian always required some lookup table and that felt like a bit of a hack. I’ve tested the Richards algorithm against all the dates I can find and it seems to hold up fine.