# Calculating public holiday dates

Discussion in 'NZ Computing' started by Joe Black, Oct 6, 2003.

1. ### Joe BlackGuest

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

Joe Black, Oct 6, 2003

2. ### Nicolaas HawkinsGuest

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.

Nicolaas Hawkins, Oct 6, 2003

3. ### JayGuest

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/28)*(1-int(\$i/28)*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;
}

Jay, Oct 6, 2003
4. ### Ralph FoxGuest

On Mon, 6 Oct 2003 15:48:41 +1300, in article
<tK4gb.169281\$>, 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/setTemplate:singlecontent/contentTypeA/conWebDoc/contentId/350

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

Other...
http://members.brabant.chello.nl/~h.reints/easter/index.htm?frame=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

Ralph Fox, Oct 6, 2003
5. ### R. G. 'Stumpy' MarshGuest

In message <Xns940CA5DC7FE01nrph@202.37.66.2>, Nicolaas Hawkins
<> 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/>

R. G. 'Stumpy' Marsh, Oct 6, 2003
6. ### T-BoyGuest

In article <tK4gb.169281\$>, 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 28)*(1 - (I div 28)*(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

T-Boy, Oct 6, 2003
7. ### HowhardGuest

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

Howhard, Oct 6, 2003
8. ### Joe BlackGuest

Thanks a lot everyone for your help.

Regards - Joe

Joe Black, Oct 6, 2003
9. ### JayGuest

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.

Jay, Oct 6, 2003
10. ### Nicolaas HawkinsGuest

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/28)*(1-int(\$i/28)*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.

Nicolaas Hawkins, Oct 6, 2003
11. ### JayGuest

Nicolaas Hawkins wrote:

> 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/28)*(1-int(\$i/28)*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.
>

You don't have to know any Perl - just run the program!

Jay, Oct 7, 2003
12. ### Nicolaas HawkinsGuest

On 07 Oct 2003 , Jay wrote :

> Nicolaas Hawkins wrote:
>
>> 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/28)*(1-int(\$i/28)*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.
>>

>
> You don't have to know any Perl - just run the program!
>

Yeah, OK. No interpreter, no compiler, no nothing. Just run the program.
Yeah, right - I should koko!

--
Nicolaas.

- Born at night, I was. Born LAST night, I wasn't.

Nicolaas Hawkins, Oct 7, 2003
13. ### JayGuest

Nicolaas Hawkins wrote:

> On 07 Oct 2003 , Jay wrote :
>
>> Nicolaas Hawkins wrote:
>>
>>> 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/28)*(1-int(\$i/28)*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.
>>>

>>
>> You don't have to know any Perl - just run the program!
>>

>
> Yeah, OK. No interpreter, no compiler, no nothing. Just run the program.
> Yeah, right - I should koko!
>

Would you like someone to turn on your computer for you?

Jay, Oct 7, 2003
14. ### Nicolaas HawkinsGuest

On 07 Oct 2003 , Jay wrote :

> Nicolaas Hawkins wrote:
>
>> On 07 Oct 2003 , Jay wrote :
>>
>>> Nicolaas Hawkins wrote:
>>>
>>>> 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/28)*(1-int(\$i/28)*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.
>>>>
>>>
>>> You don't have to know any Perl - just run the program!
>>>

>>
>> Yeah, OK. No interpreter, no compiler, no nothing. Just run the
>> program. Yeah, right - I should koko!
>>

>
> Then get an interpreter! What a dickhead thing to complain about.
>
>
> Would you like someone to turn on your computer for you?
>
>

I hope you feel better now that you have got that little dose of vitriol

Now, I have got a suggestion for you: go and get stuffed!

--
Nicolaas.

- People like you are the reason we have middle fingers.

Nicolaas Hawkins, Oct 7, 2003
15. ### T-BoyGuest

In article <bltraq\$fvem6\$-berlin.de>,
says...

> >
> > Yeah, OK. No interpreter, no compiler, no nothing. Just run the program.
> > Yeah, right - I should koko!
> >

>
> Then get an interpreter! What a dickhead thing to complain about.
>
>
> Would you like someone to turn on your computer for you?

If he turns his computer on the custom IE logo goes round again. If he
leaves it off, it doesn't. (It was your own brilliant logic, that one)

--
Duncan

T-Boy, Oct 7, 2003
16. ### JayGuest

T-Boy wrote:

> In article <bltraq\$fvem6\$-berlin.de>,
> says...
>
>> >
>> > Yeah, OK. No interpreter, no compiler, no nothing. Just run the
>> > program. Yeah, right - I should koko!
>> >

>>
>> Then get an interpreter! What a dickhead thing to complain about.
>>
>>
>> Would you like someone to turn on your computer for you?

>
> If he turns his computer on the custom IE logo goes round again.

No it doesn't. He has to start up IE for that.

> If he
> leaves it off, it doesn't. (It was your own brilliant logic, that one)

You are very confused.
IE is a program, a computer is a machine.

Jay, Oct 7, 2003
17. ### JayGuest

Nicolaas Hawkins wrote:

> On 07 Oct 2003 , Jay wrote :
>
>> Nicolaas Hawkins wrote:
>>
>>> On 07 Oct 2003 , Jay wrote :
>>>
>>>> Nicolaas Hawkins wrote:
>>>>
>>>>> 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/28)*(1-int(\$i/28)*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.
>>>>>
>>>>
>>>> You don't have to know any Perl - just run the program!
>>>>
>>>
>>> Yeah, OK. No interpreter, no compiler, no nothing. Just run the
>>> program. Yeah, right - I should koko!
>>>

>>
>> Then get an interpreter! What a dickhead thing to complain about.
>>
>>
>> Would you like someone to turn on your computer for you?
>>
>>

>
> I hope you feel better now that you have got that little dose of vitriol
>
> Now, I have got a suggestion for you: go and get stuffed!

Why? Does "stuffed" emulate Perl?
You should go and get perl.

Jay, Oct 7, 2003
18. ### HowhardGuest

Jay wrote:

> Why? Does "stuffed" emulate Perl?
> You should go and get perl.

Great riposte!

Howhard, Oct 9, 2003