-
-
Save tdoumas/5677955e2f8ef5b284dc2c39d53dbd48 to your computer and use it in GitHub Desktop.
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
/// <summary> | |
/// Get Catholic easter for requested year | |
/// </summary> | |
/// <param name="year">Year of easter</param> | |
/// <returns>DateTime of Catholic Easter</returns> | |
public static DateTime GetCatholicEaster(int year) | |
{ | |
var month = 3; | |
var a = year % 19 + 1; | |
var b = year / 100 + 1; | |
var c = (3 * b) / 4 - 12; | |
var d = (8 * b + 5) / 25 - 5; | |
var e = (5 * year) / 4 - c - 10; | |
var f = (11 * a + 20 + d - c) % 30; | |
if (f == 24) | |
f++; | |
if ((f == 25) && (a > 11)) | |
f++; | |
var g = 44 - f; | |
if (g < 21) | |
g = g + 30; | |
var day = (g + 7) - ((e + g) % 7); | |
if (day > 31) | |
{ | |
day = day - 31; | |
month = 4; | |
} | |
return new DateTime(year, month, day); | |
} |
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
/// <summary> | |
/// Get Orthodox easter for requested year | |
/// </summary> | |
/// <param name="year">Year of easter</param> | |
/// <returns>DateTime of Orthodox Easter</returns> | |
public static DateTime GetOrthodoxEaster(int year) | |
{ | |
var a = year % 19; | |
var b = year % 7; | |
var c = year % 4; | |
var d = (19 * a + 16) % 30; | |
var e = (2 * c + 4 * b + 6 * d) % 7; | |
var f = (19 * a + 16) % 30; | |
var key = f + e + 3; | |
var month = (key > 30) ? 5 : 4; | |
var day = (key > 30) ? key - 30 : key; | |
return new DateTime(year, month, day); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment