Release 1.08 of Date::Holidays had some issues with the test suite, which resulted in numerous failure reports from CPAN-testers, please see issue #21 for details.
This resulted in release 1.09, which addressed the problem with the bad tests. At the same time it however demonstrated issues with the integration towards Date::Holidays::NZ and Date::Holidays::SK, so issues #22 and #23 was created respectively.
Issue #22 has now been addressed in release 1.10 and next up is 1.11, which is planned to address issue #23 unless something else comes up.
The adaptation of Date::Holidays::NZ also supports the regional parameter described in: Date::Holidays::NZ.
So checking if New Years Day is a holiday in New Zealand, via Date::Holidays:
use Date::Holidays;
my $dh = Date::Holidays->new( countrycode => 'nz' );
if ($dh->is_holiday(year => 2018, month => 1, day => 1) {
print “It is\n”;
}
And in particular for the region of Auckland (see Date::Holidays::NZ for details).
use Date::Holidays;
my $dh = Date::Holidays->new( countrycode => 'nz' );
if ($dh->is_holiday(year => 2018, month => 1, day => 1, region => 2) {
print “In Auckland it is\n”;
}
You can also get a list of holidays:
use Date::Holidays;
use Data::Dumper;
my $dh = Date::Holidays->new( countrycode => 'nz' );
my $holidays_hashref = $dh->holidays(year => 2018);
print STDERR Dumper $holidays_hashref;
$VAR1 = {
'0206' => 'Waitangi Day',
'0402' => 'Easter Monday',
'0102' => 'Day after New Years Day',
'1022' => 'Labour Day',
'1226' => 'Boxing Day',
'1225' => 'Christmas Day',
'0330' => 'Good Friday',
'0425' => 'ANZAC Day',
'0604' => 'Queens Birthday',
'0101' => 'New Years Day'
};
And based on region:
use Date::Holidays;
use Data::Dumper;
my $dh = Date::Holidays->new( countrycode => 'nz' );
my $holidays_hashref = $dh->holidays(year => 2018, region => 2);
print STDERR Dumper $holidays_hashref;
$VAR1 = {
'0129' => 'Auckland Anniversary Day',
'1022' => 'Labour Day',
'0101' => 'New Years Day',
'0402' => 'Easter Monday',
'1225' => 'Christmas Day',
'0330' => 'Good Friday',
'1226' => 'Boxing Day',
'0102' => 'Day after New Years Day',
'0425' => 'ANZAC Day',
'0206' => 'Waitangi Day',
'0604' => 'Queens Birthday'
};
Feedback most welcome,
jonasbn
Top comments (3)
What adds the "smart double quotes" to the code?
I use plain Markdown code fence with programming language perl specified.
Please see: the Markdown cheatsheet as pointed to by the editor guide on dev.to
I cannot demonstrate it here, but I wrote up a TIL on how to do it for GitHub flavoured Markdown