Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > NZ Computing > Calculating public holiday dates

Reply
Thread Tools

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


 
Reply With Quote
 
 
 
 
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.
 
Reply With Quote
 
 
 
 
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;
}

 
Reply With Quote
 
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
 
Reply With Quote
 
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/>
 
Reply With Quote
 
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
 
Reply With Quote
 
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
the task you described.


 
Reply With Quote
 
Joe Black
Guest
Posts: n/a
 
      10-06-2003
Thanks a lot everyone for your help.

Regards - Joe


 
Reply With Quote
 
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
> the task you described.


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

 
Reply With Quote
 
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSE 4 11-15-2006 02:40 AM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola Microsoft Certification 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSD 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd realexxams@yahoo.com Microsoft Certification 0 05-10-2006 02:35 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM



Advertisments