Date-Holidays-KZ
view release on metacpan or search on metacpan
lib/Date/Holidays/KZ.pm view on Meta::CPAN
=head2 $Date::Holidays::KZ::strict
Allows you to return an error if the requested date is outside the determined times.
Default is 0.
=cut
our $strict = 0;
use Carp;
use Time::Piece;
use List::Util qw/ first /;
# internal date formatting alike ISO 8601: MMDD
my @REGULAR_HOLIDAYS = (
{
name => 'ÐовÑй год',
days => [ qw( 0101 0102 ) ],
},
{
name => 'ÐÑавоÑлавное ÑождеÑÑво',
days => '0107',
},
{
name => 'ÐеждÑнаÑоднÑй женÑкий денÑ',
days => '0308',
},
{
name => 'ÐаÑÑÑз мейÑамÑ',
days => [ qw( 0321 0322 0323 ) ],
},
{
name => 'ÐÑаздник единÑÑва наÑода ÐазаÑ
ÑÑана',
days => '0501',
},
{
name => 'ÐÐµÐ½Ñ Ð·Ð°ÑиÑника ÐÑеÑеÑÑва',
days => '0507',
},
{
name => 'ÐÐµÐ½Ñ ÐобедÑ',
days => '0509',
},
{
name => 'ÐÐµÐ½Ñ Ð¡ÑолиÑÑ',
days => '0706',
},
{
name => 'ÐÐµÐ½Ñ ÐонÑÑиÑÑÑии РеÑпÑблики ÐазаÑ
ÑÑан',
days => '0830',
},
{
name => 'ÐÐµÐ½Ñ ÐеÑвого ÐÑезиденÑа РеÑпÑблики ÐазаÑ
ÑÑан',
days => '1201',
},
{
name => 'ÐÐµÐ½Ñ ÐезавиÑимоÑÑи',
days => [ qw( 1216 1217 ) ],
},
# ÐÑÑбан-айÑа goes to HOLIDAYS_SPECIAL because based on the muslim calendar
);
my %HOLIDAYS_SPECIAL = (
2016 => [ qw( 0104 0307 0502 0510 0912 1219 ) ],
2017 => [ qw( 0103 0320 0508 0707 0901 1218 1219 ) ],
2018 => [ qw( 0821 0309 0508 0430 0831 1203 1218 1231 ) ],
2019 => [ qw( 0325 0510 0708 1202 0811 ) ],
2020 => [ qw( 0103 0309 0324 0325 0508 0831 1218 ) ],
2021 => [ qw( 0104 0324 0503 0510 0705 0720 0910 ) ],
2022 => [ qw( 0103 0104 0502 0510 0307 0829 1219 ) ],
);
my %BUSINESS_DAYS_ON_WEEKENDS = (
2016 => [ qw( 0305 ) ],
2017 => [ qw( 0318 0701 ) ],
2018 => [ qw( 0303 0505 0825 1229 ) ],
2019 => [ qw( 0504 ) ],
2020 => [ qw( 0105 1220 ) ],
2021 => [ qw( 0703 ) ],
2022 => [ qw( 0305 0827 ) ],
);
my %SHORT_BUSINESS_DAYS = (
);
=head2 is_holiday( $year, $month, $day )
Determine whether this date is a KZ holiday. Returns holiday name or undef.
=cut
sub is_holiday {
my ( $year, $month, $day ) = @_;
croak 'Bad params' unless $year && $month && $day;
return holidays( $year )->{ _get_date_key($month, $day) };
}
=head2 is_kz_holiday( $year, $month, $day )
Alias for is_holiday().
=cut
sub is_kz_holiday {
goto &is_holiday;
}
=head2 holidays( $year )
Returns hash ref of all KZ holidays in the year.
=cut
my %cache;
sub holidays {
my $year = shift or croak 'Bad year';
return $cache{ $year } if $cache{ $year };
( run in 1.014 second using v1.01-cache-2.11-cpan-8dfa8b56332 )