I came upon the need to calculate Orthodox and Catholic easter for every possible year. After finding the algorithms online, I implement the following two methods.

*(Of course since they return DateTime, “every possible year” is not quite accurate! Except this, both algorithms have problems after year 4200. You can read more about it here: http://en.wikipedia.org/wiki/Computus)*

This is for the Orthodox Easter:

/// <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 ) {
int a = year % 19;
int b = year % 7;
int c = year % 4;
int d = (19 * a + 16) % 30;
int e = (2 * c + 4 * b + 6 * d) % 7;
int f = (19 * a + 16) % 30;
int key = f + e + 3;
int month = (key > 30) ? 5 : 4;
int day = (key > 30) ? key - 30 : key;
return new DateTime( year, month, day );
}

With the help of this method you can use the following link to calculate all Greek Public Holidays: https://mycodepad.wordpress.com/2013/04/25/c-calculating-all-greek-holidays-for-any-given-year/

And this is for the Catholic Easter:

/// <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 ) {
int month = 3;
int G = year % 19 + 1;
int C = year / 100 + 1;
int X = (3 * C) / 4 - 12;
int Y = (8 * C + 5) / 25 - 5;
int Z = (5 * year) / 4 - X - 10;
int E = (11 * G + 20 + Y - X) % 30;
if (E == 24) { E++; }
if ((E == 25) && (G > 11)) { E++; }
int N = 44 - E;
if (N < 21) { N = N + 30; }
int P = (N + 7) - ((Z + N) % 7);
if (P > 31) {
P = P - 31;
month = 4;
}
return new DateTime( year, month, P );
}

### Like this:

Like Loading...

*Related*

Pingback: C#: Calculating all Greek Public Holidays for any given year | My CodePad