11,924,469 members (58,843 online)
alternative version

77.9K views
15 bookmarked
Posted

# Calculating Easter Sunday

, 23 Nov 2001
 Rate this:
How to find Easter Sunday and Ash Wednesday

## Introduction

Looking through old Pascal sources I found an algorithm to calculate Easter Sunday. I reinterpreted it to C++ and packed it into a small MFC dialog application.

The sample calculates Easter from 1970 to 2037. Responsible for the limitation is the function `mktime`, used to calculate the offset to ash. Basically `GetEasterSunday` is able to calculate Easter from 1583 (beginning of Gregorian calendar) to 2499 (end of correction values).

Ash Wednesday is 46 days before Easter Sunday.

```void
CEasterDlg::GetEasterSunday( WORD wYear, WORD& wMonth, WORD& wDay )
{
// calculate easter sunday
// [in]  wYear  - 4-digit year to calculate (but not before 1583)
// [out] wMonth - month of easter sunday
// [out] wDay   - day of easter sunday

WORD wCorrection = 0;

if( wYear < 1700 )      wCorrection = 4;
else if( wYear < 1800 ) wCorrection = 5;
else if( wYear < 1900 ) wCorrection = 6;
else if( wYear < 2100 ) wCorrection = 0;
else if( wYear < 2200 ) wCorrection = 1;
else if( wYear < 2300 ) wCorrection = 2;
else if( wYear < 2500 ) wCorrection = 3;

wDay = (19 * (wYear % 19) + 24) % 30;
wDay = 22 + wDay + ((2 * (wYear % 4) + 4 * (wYear % 7) + 6 * wDay + 5 + wCorrection) % 7);

if( wDay > 31 )
{
wMonth = 4;
wDay -= 31;
}
else
{
wMonth = 3;
}
}
```

http://aa.usno.navy.mil/data/docs/easter.html JavaScript that computes easter sunday.
http://www.hourworld.com/easter.htm More algorithms how to calculate.

Have fun.

A list of licenses authors might use can be found here

## Share

 Web Developer Germany
No Biography provided

## You may also be interested in...

 First Prev Next
 The algorithm is incorrect Sire40422-Mar-05 5:42 Sire404 22-Mar-05 5:42
 There are better algorithms. Willzyba22-Nov-04 4:22 Willzyba 22-Nov-04 4:22
 It does not take into account all the Christians Alexandru Savescu27-Nov-01 13:39 Alexandru Savescu 27-Nov-01 13:39
 Just what I was looking for! Matt Gullett26-Nov-01 10:09 Matt Gullett 26-Nov-01 10:09