Created
May 4, 2016 11:25
-
-
Save atk/4521dd1a92cc0f8c6f5bb6a45ec2b0ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// golfed-down JS code to calculate the date of easter sunday for a given year | |
// based on the Gaussian Easter Formula (https://en.wikipedia.org/wiki/Computus) | |
function(y){var a=y%19,b=(19*a+24)%30,d=b+(2*(y%4)+4*(y%7)+6*b+5)%7;d-=d^35&(d^34|b^28|a<11)?0:7;y=new Date(y,2,22+d);return y} | |
function( | |
y // year input, later used as date object / return value | |
){ | |
// calculate moon parameter | |
var a = y % 19, | |
// get the seed for the first full moon in spring | |
b = (19 * a + 24) % 30, | |
// day correction for sunday | |
d = b + (2 * (y % 4) + 4 * (y % 7) + 6 * b + 5) % 7; | |
// exceptions: d must not be 35 and not 34 if b is also 28 and a < 11 | |
d -= d ^ 35 & (d ^ 34 | b ^ 28 | a < 11) ? 0 : 7; | |
// create date object; use the interesting property that you can set dates beyond the | |
y = new Date(y, 2, 22 + d); | |
// return easter date | |
return y | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment