Easter Sunday Calculator
I always find myself wondering when Easter Sunday will be next year. Not so much
for the religious significance but I get Good Friday off and here, Easter Monday
is also a holiday. So it's nice to know when I get a nice long weekend. I also wondered
who the heck decides when Easter Sunday is. Come to find out, no one decides. It's
actually the first Sunday after the Paschal Full Moon. huh? With a little research,
I came up with this algorithum to tell me when Easter Sunday is for any year between
1753-4099.
I have also built this tool into this web page, so go ahead, type in a year to see
when Easter Sunday will be.
Enter year
|
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| 30 | 31 | 1 | 2 | 3 | 4 | 5 |
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 1 | 2 | 3 |
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
And of course, the code:
Date Released: June 19 2007
Code: C# - Visual Studio 2005
1 private
DateTime easterSunday(Int32
year)
2
{
3
// variables
4
Int32 firstTwoDigitsOfYear
= Convert.ToInt32(year / 100);
5
Int32 remainder =
Convert.ToInt32(firstTwoDigitsOfYear % 19);
6
7
//Step1: Calculate the Paschal Full Moon
8
Int32 pfm =
Convert.ToInt32((firstTwoDigitsOfYear - 15) / 2 + 202 - 11 * remainder);
9
10
if (firstTwoDigitsOfYear ==
21) { pfm--; }
11
else
if (firstTwoDigitsOfYear == 24) { pfm--; }
12
else
if (firstTwoDigitsOfYear == 25) { pfm--; }
13
else
if (firstTwoDigitsOfYear >= 27 && firstTwoDigitsOfYear <=
32) { pfm--; }
14
else
if (firstTwoDigitsOfYear == 33) { pfm -= 2; }
15
else
if (firstTwoDigitsOfYear == 34) { pfm--; }
16
else
if (firstTwoDigitsOfYear == 35) { pfm--; }
17
else
if (firstTwoDigitsOfYear == 36) { pfm -= 2; }
18
else
if (firstTwoDigitsOfYear == 37) { pfm -= 2; }
19
else
if (firstTwoDigitsOfYear == 38) { pfm--; }
20
else
if (firstTwoDigitsOfYear == 39) { pfm -= 2; }
21
else
if (firstTwoDigitsOfYear == 40) { pfm -= 2; }
22
pfm = (pfm % 30);
23
24
Int32 temp1 = (pfm + 21);
25
if (pfm == 29) { temp1--; }
26
if (pfm == 28 && remainder
> 10) { temp1--; }
27
28
// Step2: Find the next sunday after
the pfm
29
Int32 temp2 =
Convert.ToInt32((temp1 - 19) % 7);
30
Int32 temp3 =
Convert.ToInt32((40 - firstTwoDigitsOfYear) % 4);
31
if (temp3 == 3) { temp3++;
}
32
if (temp3 > 1) { temp3++;
}
33
34
pfm = Convert.ToInt32(year
% 100);
35
Int32 temp4 =
Convert.ToInt32((pfm + pfm / 4) % 7);
36
37
Int32 temp5 =
Convert.ToInt32(((20 - temp2 - temp3 - temp4) % 7) + 1);
38
39
Int32 day = (temp1 + temp5);
40
41
// Step3: Return the date
42
Int32 month = 0;
43
44
if (day > 31) { day = day
- 31; month = 4; }
45
else { month = 3; }
46
47
string s = (day.ToString()
+ "/" + month.ToString() +
"/" + year.ToString());
48
49
DateTime dt;
50
DateTime.TryParse(s, out dt);
51
52
return dt;
53
54
}