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.

1 2 3 4 5 6 7 8 9 10 11 12 |
function getEasterSunday(year:Number):Date { 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 ) return easter } |

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.

## 2 comments

Hello! would you happen to have the formula you would use in excel to compute?

Thank you!

Hi Rosa, I don’t have a VB version of the code but the formula should work in any language. There’s some VB Easter code here if you prefer: http://www.cpearson.com/excel/holidays.htm

Regarding Excel, you need to be careful if you work with historical dates as Excel assumes 1900 was a leap year (it wasn’t). This causes some date calculations to blow up. The official MS docs are here: http://support.microsoft.com/kb/214058