Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   NZ Computing (http://www.velocityreviews.com/forums/f47-nz-computing.html)
-   -   Calculating public holiday dates (http://www.velocityreviews.com/forums/t567948-calculating-public-holiday-dates.html)

Joe Black 10-06-2003 02:48 AM

Calculating public holiday dates
 
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 10-06-2003 03:18 AM

Re: Calculating public holiday dates
 
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 10-06-2003 04:17 AM

Re: Calculating public holiday dates
 
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;
}


Ralph Fox 10-06-2003 06:47 AM

Re: Calculating public holiday dates
 
On Mon, 6 Oct 2003 15:48:41 +1300, in article
<tK4gb.169281$JA5.4222276@news.xtra.co.nz>, 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 10-06-2003 07:20 AM

Re: Calculating public holiday dates
 
In message <Xns940CA5DC7FE01nrph@202.37.66.2>, Nicolaas Hawkins
<raptor@top.net.nz> 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 10-06-2003 09:10 AM

Re: Calculating public holiday dates
 
In article <tK4gb.169281$JA5.4222276@news.xtra.co.nz>, 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

Howhard 10-06-2003 09:24 AM

Re: Calculating public holiday dates
 
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.



Joe Black 10-06-2003 09:30 AM

Re: Calculating public holiday dates
 
Thanks a lot everyone for your help.

Regards - Joe



Jay 10-06-2003 10:38 AM

Re: Calculating public holiday dates
 
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.


Nicolaas Hawkins 10-06-2003 06:09 PM

Re: Calculating public holiday dates
 
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.


All times are GMT. The time now is 05:59 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.