And here the Javascript implementation:
Code:
/**
* @param year the year of which easter has to be calculated
* @param option calculate other date than easter (offset in days)
* @returns JD of Easter date
*/
function easter(year, option)
{
var golden, solar, lunar, pfm, dom, tmp, easterday,d;
/* the Golden number */
golden = (year % 19) + 1;
if ( year <= 1752 )
{
/* JULIAN CALENDAR */
/* the "Dominical number" - finding a Sunday */
dom = (year + Math.floor(year/4) + 5) % 7;
if (dom < 0) dom += 7;
/* uncorrected date of the Paschal full moon */
pfm = (3 - (11*golden) - 7) % 30;
if (pfm < 0) pfm += 30;
}
else
{
/* GREGORIAN CALENDAR */
/* the "Dominical number" - finding a Sunday */
dom = (year + Math.floor(year/4) - Math.floor(year/100) + Math.floor(year/400)) % 7;
if (dom < 0) dom += 7;
/* the solar and lunar corrections */
solar = Math.floor((year-1600)/100) - Math.floor((year-1600)/400);
lunar = Math.floor((Math.floor((year-1400) / 100) * 8) / 25);
/* uncorrected date of the Paschal full moon */
pfm = (3 - (11*golden) + solar - lunar) % 30;
if (pfm < 0) pfm += 30;
}
/* corrected date of the Paschal full moon - days after 21st March */
if ((pfm == 29) || (pfm == 28 && golden > 11))
pfm--;
tmp = (4-pfm-dom) % 7;
if (tmp < 0) tmp += 7;
/* easterday as the number of days after 21st March */
easterday = pfm + tmp + 1;
//alert(year + ' ' + tmp + ' ' + easterday);
if (easterday < 11)
d = datetojd(new Array(year,3, easterday+21,12,0,0));
else
d = datetojd(new Array(year,4, easterday-10,12,0,0));
if (arguments.count > 1)
d += option;
d = Math.floor(d);
return d;
}
function datetojd(datestr)
{
n = datestr; // array assumed y-m-d-h-i-s
var date = new Date(n[0],n[1]-1, n[2], n[3], n[4], n[5]);
var jd = date.getTime()/86400000 + 2440588 - (date.getTimezoneOffset()/1440);
//alert(jd + ' ' + (date.getTime()/86400000 + 2440588));
return jd;
}