Solved

qow 13: how to calculate easter-days for any year?

Posted on 2002-04-01
4
611 Views
Last Modified: 2010-04-04
hi experts,

i am starting a new quest: qow = question of the week :-)
each week i will introduce a new simple? question.

now qow 13
(missed last later, thats why twice this week)

the first working solution will get the points (a graded).

sorry, top 15 experts, you are not allowed to solve this
q, only other can solve this question :-(

well the question is:
how to calculate easter-days for any year?

a little sample is needed

let see

meikl ;-)
0
Comment
Question by:kretzschmar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6909976
The question is not answerable.
Easter can only calculated from year 1 on. Before that easter is not defined.
Now tell for which calendar: Julian or Gregorian?
For the rest have a look at the Jedi Code Library. One of several ways to calculate easter sunday.
0
 
LVL 45

Expert Comment

by:aikimark
ID: 6910884
I don't think it can be calculated prior to 325 A.D.
See http://www.smart.net/~mmontes/ec-cal.html for an explanation of the algorithm and restrictions.
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 25 total points
ID: 6911380
Thats funny - this question was answered at the following page - www.delphiforfun.com, the source extract is below. You can get a running demo there as well.

http://www.delphiforfun.com/Programs/easter.htm

- source extract -

unit U_Easter;

{Calculates the date of Easter given any year.  I don't pretend to understand
the details of the algorithm.  It comes from the Art Of Programming series
of books by Donald Knuth}

{Gary Darby, www.dephiforfun.org}

interface

{..... generated code snipped ....}

implementation


Function KnuthCalcEaster(year:integer; var easter:TDateTime):String;
{From Vol 3 of The Art of Computer Programming, Donlad E. Knuth}
var
  golden,century:integer;
  Correction1,Correction2:integer;
  Sunday,Epact:Integer;
  N:Integer;
begin
 If Year <= 1582 then
     Showmessage('OK, but  results are only valid for years after 1582');
   Golden := Year mod 19  + 1 ;
   Century := Year div 100 + 1 ;
   Correction1 := trunc(3.0 * Century / 4.0) - 12;
   Correction2 := trunc((8.0 * Century + 5.0) / 25.0) - 5;
   Sunday := trunc(5.0 * year / 4.0) - Correction1 -10 ;
   Epact := (11 * Golden + 20 + Correction2 - Correction1) mod 30 ;
   IF ((Epact = 25) and (Golden > 11))  or (Epact = 24) then
      Epact := Epact + 1 ;
   N := 44 - Epact;
   if N < 21 then  N := N + 30 ;
   N := N + 7 - ((Sunday + N) mod 7) ;
   try
     {Pass a Year, Month, and Day and get a date back}
     easter:=encodedate(year,3,1)+n-1;
     result:=FormatDateTime('mmmm d',easter);
   except
     showmessage(inttostr(year)+' is an invalid year');
     result:='';
     easter:=0;
   end;
end;

Procedure TForm1.getdate(Year:integer);
{take a year, calculate Easter date and display it}
var
  iswas:string;
  s:string;
  Easter:TDateTime;
begin
  s:=Knuthcalceaster(year,Easter);
  If easter>now then iswas:=' will be on '
  else iswas:=' was on ';
  Easter2lbl.Caption:='Easter in '+inttostr(year)
   + iswas +s;
  Intedit1.text:=inttostr(year);
end;


procedure TForm1.IntEdit1KeyPress(Sender: TObject; var Key: Char);
{Get integers and show Easter when Enter key is pressed}
begin
  If key=#13 then
  begin
    Getdate(strtoint(IntEdit1.text));
    key:=#00;
  end
  else if not (key in ['0'..'9']) then
  begin  beep;  key:=#00; end;
end;

procedure TForm1.FormActivate(Sender: TObject);
var
  y,m,d:word;
  m2,d2:integer;
  e1,e2:TDateTime;
  s1,s2:string;
begin
  {set current data at start up time}
  decodedate(now,y,m,d);
  getdate(y);
end;

procedure TForm1.IntEdit1Click(Sender: TObject);
begin {also show Easter if year is clicked}
  getdate(strtoint(intedit1.text));
end;

end.
0
 
LVL 27

Author Comment

by:kretzschmar
ID: 6920602
yep, works perfect

thanks for participating on this quest

next monday the next ?simple q

meikl ;-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
creating threads in delphi 1 202
CheckListBox usage 3 97
Delphi: making a BW image transparent 10 137
Way to create an iPhone app for my customers 8 89
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question