Skip to content

Commit d2f8612

Browse files
author
rafaelk
committed
Experimental implementation of easter_date
1 parent 2aa0f73 commit d2f8612

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

_experimental/datetime/easter_date.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function easter_date(year) {
2+
// Based on algorithm from polish wikipedia (http://pl.wikipedia.org/wiki/Wielkanoc)
3+
4+
year = isNaN(year) ? new Date().getFullYear() : +year;
5+
6+
var a = year % 19,
7+
b = year / 100 | 0,
8+
c = year % 100,
9+
h = (19 * a + b - (b / 4 | 0) - ((b - ((b + 8) / 25 | 0) + 1) / 3 | 0) + 15) % 30,
10+
l = (32 + 2 * (b % 4) + 2 * (c / 4 | 0) - h - c % 4) % 7,
11+
m = Math.floor((a + 11 * h + 22 * l) / 451);
12+
13+
return new Date(year, Math.floor((h + l - 7 * m + 114) / 31) - 1, (h + l - 7 * m + 114) % 31 + 1) / 1e3 | 0;
14+
15+
}

0 commit comments

Comments
 (0)