whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

39 Visitors Online


 
...Calculate Easter Day for a specified year?
Autor: Mark Lussier
[ Print tip ]  

Tip Rating (7):  
     


function Easter(Year: Integer): TDateTime;
  {----------------------------------------------------------------}
  { Calculates and returns Easter Day for specified year.          }
  { Originally from Mark Lussier, AppVision <MLussier@best.com>.   }
  { Corrected to prevent integer overflow if it is inadvertently   }
  { passed a year of 6554 or greater.                              }
  {----------------------------------------------------------------}
var
  
nMonth, nDay, nMoon, nEpact, nSunday, nGold, nCent, nCorx, nCorz: Integer;
begin
  
{ The Golden Number of the year in the 19 year Metonic Cycle: }
  
nGold := (Year mod 19) + 1;
  { Calculate the Century: }
  
nCent := (Year div 100) + 1;
  { Number of years in which leap year was dropped in order... }
  { to keep in step with the sun: }
  
nCorx := (3 * nCent) div 4 - 12;
  { Special correction to syncronize Easter with moon's orbit: }
  
nCorz := (8 * nCent + 5) div 25 - 5;
  { Find Sunday: }
  
nSunday := (Longint(5) * Year) div 4 - nCorx - 10;
  { ^ To prevent overflow at year 6554}
  { Set Epact - specifies occurrence of full moon: }
  
nEpact := (11 * nGold + 20 + nCorz - nCorx) mod 30;
  if nEpact < 0 then
    
nEpact := nEpact + 30;
  if ((nEpact = 25) and (nGold > 11)) or (nEpact = 24) then
    
nEpact := nEpact + 1;
  { Find Full Moon: }
  
nMoon := 44 - nEpact;
  if nMoon < 21 then
    
nMoon := nMoon + 30;
  { Advance to Sunday: }
  
nMoon := nMoon + 7 - ((nSunday + nMoon) mod 7);
  if nMoon > 31 then
  begin
    
nMonth := 4;
    nDay   := nMoon - 31;
  end
  else
  begin
    
nMonth := 3;
    nDay   := nMoon;
  end;
  Easter := EncodeDate(Year, nMonth, nDay);
end{Easter}

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners