# Can you help verify australian holidays for Date::Calc?

Steffen Beyer sb at engelschall.com
Tue Apr 10 05:59:03 CDT 2001

```Dear Australian Perl Mongers,

a friend of mine (Bianca Taylor <bianca at unisolve.com.au>) provided me
with a list of Australian holidays, which I would like to include in
the next release (version 5.0) of my module "Date::Calc".

In this new version, Date::Calc will be able to perform date calculations
which take holidays into consideration.

Therefore, I would like to provide calendar profiles for as many countries
as possible, including Australia.

But although she even phoned up government officials, some doubts remained
as to whether the formulas for calculating some of the moving holidays we
came up with are correct.

Can you provide any insights, corrections or additions?

Any help is most welcome!

Can you please also forward this message to your Perl Monger mailing lists,
as well as any acquaintances or friends who might be able to help?

Here are the Australian holidays I have so far:
(First some necessary subroutines)

sub Previous_Friday
{
my(\$yy) = shift;
my(\$mm) = shift;
my(\$dd) = shift;
my(\$dow);

# If holiday falls on Saturday or Sunday, use previous Friday instead:

\$dow = Day_of_Week(\$yy,\$mm,\$dd);
if    (\$dow == 6) { (\$yy,\$mm,\$dd) = Add_Delta_Days(\$yy,\$mm,\$dd,-1); }
elsif (\$dow == 7) { (\$yy,\$mm,\$dd) = Add_Delta_Days(\$yy,\$mm,\$dd,-2); }
return(\$yy,\$mm,\$dd, at _);
}

sub Next_Monday
{
my(\$yy) = shift;
my(\$mm) = shift;
my(\$dd) = shift;
my(\$dow);

# If holiday falls on Saturday, use following Monday instead;
# if holiday falls on Sunday, use day thereafter (Monday) instead:

\$dow = Day_of_Week(\$yy,\$mm,\$dd);
if    (\$dow == 6) { (\$yy,\$mm,\$dd) = Add_Delta_Days(\$yy,\$mm,\$dd,+2); }
elsif (\$dow == 7) { (\$yy,\$mm,\$dd) = Add_Delta_Days(\$yy,\$mm,\$dd,+1); }
return(\$yy,\$mm,\$dd, at _);
}

sub Next_Monday_or_Tuesday # For second holiday of two adjacent ones!
{
my(\$yy) = shift;
my(\$mm) = shift;
my(\$dd) = shift;
my(\$dow);

# If holiday falls on Saturday, use following Monday instead;
# if holiday falls on Sunday or Monday, use next Tuesday instead
# (because Monday is already taken by adjacent holiday on the day before):

\$dow = Day_of_Week(\$yy,\$mm,\$dd);
if    (\$dow == 6 or \$dow == 7) { (\$yy,\$mm,\$dd) = Add_Delta_Days(\$yy,\$mm,\$dd,+2); }
elsif (\$dow == 1)              { (\$yy,\$mm,\$dd) = Add_Delta_Days(\$yy,\$mm,\$dd,+1); }
return(\$yy,\$mm,\$dd, at _);
}

sub Nearest_Workday
{
my(\$yy) = shift;
my(\$mm) = shift;
my(\$dd) = shift;
my(\$dow);

# If holiday falls on Saturday, use day before (Friday) instead;
# if holiday falls on Sunday, use day thereafter (Monday) instead:

\$dow = Day_of_Week(\$yy,\$mm,\$dd);
if    (\$dow == 6) { (\$yy,\$mm,\$dd) = Add_Delta_Days(\$yy,\$mm,\$dd,-1); }
elsif (\$dow == 7) { (\$yy,\$mm,\$dd) = Add_Delta_Days(\$yy,\$mm,\$dd,+1); }
return(\$yy,\$mm,\$dd, at _);
}

\$Profiles->{'AU'} = # Australia
{
"Australia Day"             => \&AU_Australia,
"Good Friday"               => "-2",
"Easter Sunday"             => "+0",
"Easter Monday"             => "+1",
"Anzac Day"                 => \&AU_Anzac,
"Christmas Day"             => \&AU_Christmas,
"Boxing Day"                => \&AU_Boxing
};

sub AU_Australia
{
my(\$year,\$label) = @_;
return &Next_Monday(\$year,1,26);
}
sub AU_Anzac
{
my(\$year,\$label) = @_;
return &Next_Monday(\$year,4,25);
}
sub AU_Christmas
{
my(\$year,\$label) = @_;
return &Next_Monday(\$year,12,25);
}
sub AU_Boxing
{
my(\$year,\$label) = @_;
return &Next_Monday_or_Tuesday(\$year,12,26);
}
sub AU_New_Year
{
my(\$year,\$label) = @_;
return &Next_Monday(\$year,1,1);
}
sub AU_Lauceston
{
my(\$year,\$label) = @_;
if (Nth_Weekday_of_Month_Year(\$year,2,3,5))
{ return Nth_Weekday_of_Month_Year(\$year,2,3,4); }
else
{ return Nth_Weekday_of_Month_Year(\$year,2,3,3); }
}
sub AU_May
{
my(\$year,\$label) = @_;
return &Next_Monday(\$year,5,1);
}

\$Profiles->{'AU-QLD'} = # Queensland
{
%{\$Profiles->{'AU'}},
"New Year's Day"            => "01.01.",
"Easter Saturday"           => "-1",
"Labour Day"                => "1/Mon/May",
"Queen's Birthday"          => "2/Mon/Jun",
"Royal Show (Brisbane)"     => "2/Wed/Aug"
};
\$Profiles->{'AU-TAS'} = # Tasmania
{
%{\$Profiles->{'AU'}},
"New Year's Day"            => "01.01.",
"Regatta Day"               => "2/Tue/Feb",
"Lauceston Cup Day"         => \&AU_Lauceston,
"King Island Show Day"      => "1/Tue/Mar", # uncertain! (maybe Tuesday after 1/Sun/Mar?)
"Eight Hour Day"            => "2/Mon/Mar", # dubious, formula probably wrong!
"Easter Saturday"           => "-1",
"Queen's Birthday"          => "2/Mon/Jun",
"Recreation Day"            => "1/Mon/Nov"  # only North Tasmania - date not confirmed!
};
\$Profiles->{'AU-SA'} =  # South Australia
{
%{\$Profiles->{'AU'}},
"New Year's Day"            => "01.01.",
"Easter Saturday"           => "-1",
"Adelaide Cup Day"          => "3/Mon/May", # uncertain! (maybe Monday after 3/Sun/May?)
"Queen's Birthday"          => "2/Mon/Jun",
"Labour Day"                => "1/Mon/Oct"
};
\$Profiles->{'AU-WA'} =  # Western Australia
{
%{\$Profiles->{'AU'}},
"New Year's Day"            => "01.01.",
"Labour Day"                => "1/Mon/Mar",
"Foundation Day"            => "1/Mon/Jun",
"Queen's Birthday"          => "1/Mon/Oct"
};
\$Profiles->{'AU-ACT'} = # Australian Capital Territory
{
%{\$Profiles->{'AU'}},
"New Year's Day"            => "01.01.",
"Canberra Day"              => "2/Mon/Mar", # dubious, formula probably wrong!
"Easter Saturday"           => "-1",
"Queen's Birthday"          => "2/Mon/Jun",
"Labour Day"                => "1/Mon/Oct"
};
\$Profiles->{'AU-NSW'} = # New South Wales
{
%{\$Profiles->{'AU'}},
"New Year's Day"            => \&AU_New_Year,
"Easter Saturday"           => "-1",
"Queen's Birthday"          => "2/Mon/Jun",
"Labour Day"                => "1/Mon/Oct"
};
\$Profiles->{'AU-NT'} =  # Northern Territory
{
%{\$Profiles->{'AU'}},
"New Year's Day"            => "01.01.",
"Easter Saturday"           => "-1",
"May Day"                   => \&AU_May,
"Queen's Birthday"          => "2/Mon/Jun",
"Picnic Day"                => "1/Mon/Aug"
};
\$Profiles->{'AU-VIC'} = # Victoria
{
%{\$Profiles->{'AU'}},
"New Year's Day"            => \&AU_New_Year,
"Labour Day"                => "2/Mon/Mar",
"Queen's Birthday"          => "2/Mon/Jun",
"Melbourne Cup Day"         => "1/Tue/Nov"
};