While working on a script to tell me the date of the next fortnightly recycling collection in my area, I’ve had cause to research the calculation of Easter Day. (Easter Monday’s a bank holiday, so any collections that week will be a day later.) It’s quite a complex process, based on full moons and Vernal Equinoxes. One of the calculations I found on the Web actually works and looks like this when translated into AppleScript:

```
on EasterDay(y) -- y is the year number.
-- Based on a calculation on the BBC's h2g2 Web site:
-- <http://www.bbc.co.uk/dna/h2g2/A653267>
set a to y mod 19
set b to y div 100
set c to y mod 100
set d to b div 4
set e to b mod 4
set f to c div 4
set g to c mod 4
set h to (b + 8) div 25
set i to (b - h + 1) div 3
set j to (19 * a + b - d - i + 15) mod 30
set k to (32 + 2 * e + 2 * f - j - g) mod 7
set m to (a + 11 * j + 22 * k) div 451
set n to j + k - 7 * m + 114
set theDay to n mod 31 + 1
set theMonth to n div 31
return {theDay, theMonth}
end EasterDay
EasterDay(2006)
--> {16, 4} -- Sunday 16th April
```

This is apparently only guaranteed for years between 1700 and 2299! For my own purposes, I want the result as an AppleScript date.

```
on EasterDay(y)
-- Based on a calculation on the BBC's h2g2 Web site:
-- <http://www.bbc.co.uk/dna/h2g2/A653267>
set {a, b, c} to {y mod 19, y div 100, y mod 100}
set j to (19 * a + b - b div 4 - (b - (b + 8) div 25 + 1) div 3 + 15) mod 30
set k to (32 + 2 * (b mod 4 + c div 4) - j - c mod 4) mod 7
set n to j + k - (a + 11 * j + 22 * k) div 451 * 7 + 114
-- Get 1st January in the target year.
set theDate to date "Wednesday 1 January 1000 00:00:00"
set theDate's year to y
tell theDate + (n div 31 - 1) * 32 * days -- Get a date in the (n div 31)th month of the year.
return it + (n mod 31 + 1 - (its day)) * days -- Return the result + (target day - actual day) days.
end tell
end EasterDay
EasterDay(2006)
--> date "Sunday 16 April 2006 00:00:00"
```