Velocity Reviews > Calculating public holiday dates

# Calculating public holiday dates

Joe Black
Guest
Posts: n/a

 10-06-2003
Hi

I am writing a programme that needs to be able to calculate public holiday
dates.

Does anyone know the rules for deciding what dates Good Friday and Easter
Monday fall on?
(One website I found even mentions an Easter Tuesday (29 march 2005)!

Thanks - Joe

Nicolaas Hawkins
Guest
Posts: n/a

 10-06-2003
On 06 Oct 2003 , Joe Black wrote :

> Hi
>
> I am writing a programme that needs to be able to calculate public
> holiday dates.
>
> Does anyone know the rules for deciding what dates Good Friday and
> Easter Monday fall on?
> (One website I found even mentions an Easter Tuesday (29 march 2005)!
>
> Thanks - Joe
>
>
>

Easter Sunday is the first Sunday after the first full moon after the
autumnal equinox.

--
Nicolaas.

- Lawyers & hookers: Both hired to get their client off.

Jay
Guest
Posts: n/a

 10-06-2003
Nicolaas Hawkins wrote:

> On 06 Oct 2003 , Joe Black wrote :
>
>> Hi
>>
>> I am writing a programme that needs to be able to calculate public
>> holiday dates.
>>
>> Does anyone know the rules for deciding what dates Good Friday and
>> Easter Monday fall on?
>> (One website I found even mentions an Easter Tuesday (29 march 2005)!
>>
>> Thanks - Joe
>>
>>
>>

>
> Easter Sunday is the first Sunday after the first full moon after the
> autumnal equinox.
>

In other (Perl) words:

sub isEasterSunday
{
# Must normalize the date to account for arithmetic on \$dd arg
my \$xx;
my (\$yy,\$mm,\$dd) = @_;
(\$xx,\$xx,\$xx,\$dd,\$mm,\$yy,\$xx,\$xx,\$xx) =
localtime(mktime(0,0,12,\$dd,\$mm-1,\$y
y-1900));
\$mm++;
\$yy += 1900;

my \$y = \$yy;
my \$c = int(\$y/100);
my \$n = \$y - 19*int(\$y / 19);
my \$k = int((\$c - 17)/25);
my \$i = \$c - int(\$c/4) - int((\$c - \$k)/3) + 19*\$n + 15;
\$i = \$i - 30*int(\$i/30);
\$i = \$i - int(\$i/2*(1-int(\$i/2*int(29/(\$i + 1))*int((21 - \$n)/11));
my \$j = \$y + int(\$y/4) + \$i + 2 - \$c + int(\$c/4);
\$j = \$j - 7*int(\$j/7);
my \$l = \$i - \$j;
my \$m = 3 + int((\$l + 40)/44);
my \$d = \$l + 28 - 31*int(\$m/4);

return \$TRUE if \$m == \$mm && \$d == \$dd;
return \$FALSE;
}

Ralph Fox
Guest
Posts: n/a

 10-06-2003
On Mon, 6 Oct 2003 15:48:41 +1300, in article
<tK4gb.169281\$(E-Mail Removed)>, Joe Black wrote:

> I am writing a programme that needs to be able to calculate public holiday
> dates.
>
> Does anyone know the rules for deciding what dates Good Friday and Easter
> Monday fall on?

Plenty of good descriptions of the rules and actual algorithms
can be found on the web.

U.K. National Maritime Museum...
http://www.nmm.ac.uk/site/request/se.../contentId/350

U.S. Naval Observatory...
http://aa.usno.navy.mil/faq/docs/easter.html

Other...
http://members.brabant.chello.nl/~h....easteralg1.htm
http://www.delphiforfun.org/Programs/easter.htm
http://www.aaxn28.ukgateway.net/Church/easter.htm

> (One website I found even mentions an Easter Tuesday (29 march 2005)!
>
> Thanks - Joe

--
Cheers,
Ralph

"There is only one boss, the customer. And he can fire everybody in
the company from the chairman on down, simply by spending his money
somewhere else." -- Sam Walton

R. G. 'Stumpy' Marsh
Guest
Posts: n/a

 10-06-2003
In message <Xns940CA5DC7FE01nrph@202.37.66.2>, Nicolaas Hawkins
<(E-Mail Removed)> wrote:

>Easter Sunday is the first Sunday after the first full moon after the
>autumnal equinox.

Usually.

The church has a more complex formula that occasionally violates this
rule of thumb. See:

<http://www.smart.net/~mmontes/nature1876.html>

Stumpy.
--
R.G. "Stumpy" Marsh Timaru, New Zealand
<http://marsh.orcon.net.nz/>

T-Boy
Guest
Posts: n/a

 10-06-2003
In article <tK4gb.169281\$(E-Mail Removed)>, joeblack99
@hotmail.com says...
> Hi
>
> I am writing a programme that needs to be able to calculate public holiday
> dates.
>
> Does anyone know the rules for deciding what dates Good Friday and Easter
> Monday fall on?
> (One website I found even mentions an Easter Tuesday (29 march 2005)!
>
> Thanks - Joe

This is it, in Delphi..
{************************************************* **********************
*****}
{** Return the date for easter sunday, it can be in march or april.
**}
{** If year = 0 then year = the current year
**}
{************************************************* **********************
*****}
Function TAdrockDates.ReturnEasterSunday(Year : Word) : TDateTime;
Var
century, G, I, J, K, L, EasterMonth, EasterDay : Integer;
fYear, fMonth, fDay : Word;
begin
DecodeDate(Now, fYear, fMonth, fDay);
if (Year <> 0) then
fYear := Year;

Century := fyear div 100;
G := fyear mod 19;
K := (Century - 17) div 25;
I := (Century - Century div 4 - (Century - K) div 3 + 19*G + 15) mod
30;
I := I - (I div 2*(1 - (I div 2*(29 div (I + 1))*((21 - G) div
11));
J := (fYear + fYear div 4 + I + 2 - Century + Century div 4) mod 7;
L := I - J;
EasterMonth := 3 + (L + 40)div 44;
EasterDay := L + 28 - 31*(EasterMonth div 4);

Result := EncodeDate(fYear, EasterMonth, EasterDay);
end;

--
Duncan

Howhard
Guest
Posts: n/a

 10-06-2003
Nicolaas Hawkins wrote:
> On 06 Oct 2003 , Joe Black wrote :
>
>> Hi
>>
>> I am writing a programme that needs to be able to calculate public
>> holiday dates.
>>
>> Does anyone know the rules for deciding what dates Good Friday and
>> Easter Monday fall on?
>> (One website I found even mentions an Easter Tuesday (29 march 2005)!
>>
>> Thanks - Joe
>>
>>
>>

>
> Easter Sunday is the first Sunday after the first full moon after the
> autumnal equinox.

Make that the Southern Hemisphere Autumnal Equinox ( its the Vernal equinox
in the Northern Hemishpere).

To the OP. Please post again if you find a alogorithm for it. I gave up on
logic and just listed the next 30 years of Easters when I had to implement

Joe Black
Guest
Posts: n/a

 10-06-2003
Thanks a lot everyone for your help.

Regards - Joe

Jay
Guest
Posts: n/a

 10-06-2003
Howhard wrote:

> Nicolaas Hawkins wrote:
>> On 06 Oct 2003 , Joe Black wrote :
>>
>>> Hi
>>>
>>> I am writing a programme that needs to be able to calculate public
>>> holiday dates.
>>>
>>> Does anyone know the rules for deciding what dates Good Friday and
>>> Easter Monday fall on?
>>> (One website I found even mentions an Easter Tuesday (29 march 2005)!
>>>
>>> Thanks - Joe
>>>
>>>
>>>

>>
>> Easter Sunday is the first Sunday after the first full moon after the
>> autumnal equinox.

>
> Make that the Southern Hemisphere Autumnal Equinox ( its the Vernal
> equinox in the Northern Hemishpere).
>
> To the OP. Please post again if you find a alogorithm for it. I gave up on
> logic and just listed the next 30 years of Easters when I had to implement

See my other post. That has a Perl implementation of Easter Sunday
calculation in it.

Nicolaas Hawkins
Guest
Posts: n/a

 10-06-2003
On 06 Oct 2003 , Jay wrote :

>> Easter Sunday is the first Sunday after the first full moon after the
>> autumnal equinox.
>>

>
> In other (Perl) words:
>
> sub isEasterSunday
> {
> # Must normalize the date to account for arithmetic on \$dd arg
> my \$xx;
> my (\$yy,\$mm,\$dd) = @_;
> (\$xx,\$xx,\$xx,\$dd,\$mm,\$yy,\$xx,\$xx,\$xx) =
> localtime(mktime(0,0,12,\$dd,\$mm-1,\$y
> y-1900));
> \$mm++;
> \$yy += 1900;
>
> my \$y = \$yy;
> my \$c = int(\$y/100);
> my \$n = \$y - 19*int(\$y / 19);
> my \$k = int((\$c - 17)/25);
> my \$i = \$c - int(\$c/4) - int((\$c - \$k)/3) + 19*\$n + 15;
> \$i = \$i - 30*int(\$i/30);
> \$i = \$i - int(\$i/2*(1-int(\$i/2*int(29/(\$i + 1))*int((21 -
> \$n)/11)); my \$j = \$y + int(\$y/4) + \$i + 2 - \$c + int(\$c/4);
> \$j = \$j - 7*int(\$j/7);
> my \$l = \$i - \$j;
> my \$m = 3 + int((\$l + 40)/44);
> my \$d = \$l + 28 - 31*int(\$m/4);
>
> return \$TRUE if \$m == \$mm && \$d == \$dd;
> return \$FALSE;
> }
>

You may very well be of that opinion, Jay - but I couldn't POSSIBLY comment
because I know absolutely nothing of PERL.

--
Nicolaas.

- Yield unto temptation, for verily it passeth not thy way again.