Calculation of the Easter day

In calculations involving options, one must choose to measure time in business days or calendar days. I use calendar days, and most tools that I make available on this site use calendar days as well. But some people prefer to use business days, so my Black-Scholes calculator offers both.

In the finance world, a "business year" has 252 business days. This is 365 minus 52.5 Saturdays, 52.5 Sundays and 8 holidays, like Christmas and Good Friday.

One problem with this model is being USA-centric. Different countries will have different holidays, so the business day counting is country-specific. I tried to find a common denominator in the Web calculator, including only the holidays followed by most countries.

Another problem is the calculation of moving holidays. Most worldwide holidays are fixed (e.g. Christmas) but Good Friday moves every year. I could not avoid implementing this one.

It is far easier to find references to Easter calculation. The best text I found is at http://www.assa.org.au/edm.html#Computer. The page contains an implementation of Easter calculation written in Visual Basic. I ported it to Javascript and modified it slightly to calculate Good Friday, which was the holiday of interest for me.

FWIW, the Javascript code. It takes the four-digit year as parameter, and returns an array with Good Friday's month and day. Month is in range 1-12 and day is in range 1-31. (I mention that because some C library functions adopt the convention 0-11 for month).

function calc_good_friday(y) { var m, d; var FirstDig, Remain19, temp; var tA, tB, tC, tD, tE; FirstDig = Math.floor(y / 100); Remain19 = y % 19; // calculate Pascal Full Moon date temp = Math.floor((FirstDig - 15) / 2) + 202 - 11 * Remain19; if ([21, 24, 25, 27, 28, 29, 30, 31, 32, 34, 35, 38].indexOf(FirstDig) > -1) { temp = temp - 1; } else if ([33, 36, 37, 39, 40].indexOf(FirstDig) > -1) { temp = temp - 2; } temp = temp % 30; tA = temp + 21; if (temp == 29) { tA = tA - 1; } if (temp == 28 && Remain19 > 10) { tA = tA - 1; } // find the next Sunday tB = (tA - 19) % 7; tC = (40 - FirstDig) % 4; if (tC == 3) { tC = tC + 1; } if (tC > 1) { tC = tC + 1; } temp = y % 100; tD = (temp + Math.floor(temp / 4)) % 7; tE = ((20 - tB - tC - tD) % 7) + 1; d = tA + tE; // we want good friday, not easter (sunday) d -= 2; if (d > 31) { d -= 31; m = 4; } else { m = 3; } return [m, d]; }