1. Home
  2. Computing & Technology
  3. Delphi Programming

How to calculate the date of Easter for a given year

By Zarko Gajic, About.com

Here's how to calculate the date of Easter for a given year:

~~~~~~~~~~~~~~~~~~~~~~~~~
function GetEaster(Year: Integer): TDate;
var
   y, m, d: Word;
   G, I, J, C, H, L: Integer;
   E: TDate;
begin
   G := Year mod 19;
   C := year div 100;
   H := (C - C div 4 - (8*C+13) div 25 + 19*G + 15) mod 30;
   I := H - (H div 28)*(1 - (H div 28)*(29 div (H + 1))*((21 - G) div 11)) ;
   J := (Year + Year div 4 + I + 2 - C + C div 4) mod 7;
   L := I - J;
   m := 3 + (L + 40) div 44;
   d := L + 28 - 31*(m div 4) ;
   y := Year;
   // E is the date of the full moon
   E := EncodeDate(y, m, d) ;
   // find next sunday
   while DayOfWeek(E) > 1 do
     E := E + 1;
   Result := E;
end;

{
Usage
var EasterDate: TDateTime;
...
EasterDate := GetEaster(2002) ;
}

~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Stop Windows from Displaying Critical Error Messages
« Case statement that *accepts* string values

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2002 Delphi Tips
  7. How to calculate the date of Easter for a given year

©2009 About.com, a part of The New York Times Company.

All rights reserved.