Created
April 25, 2011 20:44
-
-
Save boblail/941179 to your computer and use it in GitHub Desktop.
Calculate the date of Easter given the year
This file contains hidden or 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
public static DateTime FindEaster( int year ) { | |
int month, day, century, n, m, i, j, k, z, a, l; | |
century = year / 100; | |
n = year % 19; | |
m = (century - 17) / 25; | |
i = century - (century >> 2) - (int)((century - m) / 3) + 19 * n + 15; | |
j = i % 30; | |
z = (int)(j / 28); | |
k = j - z * (1 - z * (int)(29 / (j + 1)) * (int)((21 - n) / 11)); | |
a = year + (year >> 2) + k + 2 - century + (century >> 2); | |
l = k - (a % 7); | |
month = 3 + ((l + 40) / 44); | |
day = l + 28 - 31 * (month >> 2); | |
return new DateTime( year, month, day ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment