JavaScript version:
function getEasterDate(easterYear) {
var a, b, c, d, e, f, g, h, i, k, l, m, easterMonth, easterDay;
a = parseInt(easterYear % 19);
b = parseInt(easterYear / 100);
c = parseInt(easterYear % 100);
d = parseInt(b / 4);
e = parseInt(b % 4);
f = parseInt((b + 8) / 25);
g = parseInt((b - f + 1) / 3);
h = parseInt((19 * a + b - d - g + 15) % 30);
i = parseInt(c / 4);
k = parseInt(c % 4);
l = parseInt((32 + 2 * e + 2 * i - h - k) % 7);
m = parseInt((a + 11 * h + 22 * l) / 451);
easterMonth = parseInt((h + l - 7 * m + 114) / 31);
easterDay = parseInt(((h + l - 7 * m + 114) % 31) + 1);
// in javascript months run from 0 to 11, rather than 1 to 12!
return new Date(easterYear , easterMonth - 1, easterDay);
}
C# version:
public static DateTime GetEasterDate(int easterYear) {
int a, b, c, d, e, f, g, h, i, k, l, m, easterMonth, easterDay;
a = easterYear % 19;
b = easterYear / 100;
c = easterYear % 100;
d = b / 4;
e = b % 4;
f = (b + 8) / 25;
g = (b - f + 1) / 3;
h = (19 * a + b - d - g + 15) % 30;
i = c / 4;
k = c % 4;
l = (32 + 2 * e + 2 * i - h - k) % 7;
m = (a + 11 * h + 22 * l) / 451;
easterMonth = (h + l - 7 * m + 114) / 31;
easterDay = ((h + l - 7 * m + 114) % 31) + 1;
return new DateTime(easterYear , easterMonth, easterDay);
}
Apex Code version:
public static datetime getEasterDate(integer easterYear) {
integer a, b, c, d, e, f, n, h, i, k, l, m, easterDay, easterMonth;
a = math.mod(easterYear, 19);
b = easterYear / 100;
c = math.mod(easterYear, 100);
d = b / 4;
e = math.mod(b, 4);
f = (b + 8) / 25;
n = (b - f + 1) / 3;
h = math.mod((19 * a + b - d - n + 15), 30);
i = c / 4;
k = math.mod(c, 4);
l = math.mod((32 + 2 * e + 2 * i - h - k), 7);
m = (a + 11 * h + 22 * l) / 451;
easterDay = math.mod((h + l - 7 * m + 114), 31) + 1;
easterMonth = (h + l - 7 * m + 114) / 31;
return datetime.newInstance(easterYear, easterMonth, easterDay);
}