NAME
Date::Holidays::BY - Determine public holidays and business days in Belarus.
SYNOPSIS
use Date::Holidays::BY;
my $holidays = Date::Holidays::BY::holidays( 2024 );
# {
# "0101" => "New Year",
# ...
# "1225" => "Christmas (Catholic Christmas)"
# }
if ( my $holidayname = Date::Holidays::BY::is_holiday( 2007, 1, 1 ) ) {
print "Is a holiday: $holidayname\n";
}
if ( Date::Holidays::BY::is_business_day( 2012, 3, 11 ) ) {
print "2012-03-11 is business day on weekend\n";
}
if ( Date::Holidays::BY::is_short_business_day( 2015, 04, 30 ) ) {
print "2015-04-30 is short business day\n";
}
DESCRIPTION
Date::Holidays::BY provides functions to check if a given date is a public holiday in Belarus. This module follows the standard holiday calendar observed in Belarus, including both national holidays and specific religious observances recognized in the country.
Imports nothing by default.
CONFIGURATION VARIABLES
$Date::Holidays::BY::ref
Hash reference containing all static holiday data, including holiday names for i18n support. Dates are formatted as MMDD (ISO 8601).
HOLIDAYS_VALID_SINCE
$Date::Holidays::BY::ref->{'HOLIDAYS_VALID_SINCE'}
The module is only relevant from this year onward. Throws an exception (croak) for dates before this year.
INACCURATE_TIMES_BEFORE - INACCURATE_TIMES_SINCE
$Date::Holidays::BY::ref->{'INACCURATE_TIMES_BEFORE'}
$Date::Holidays::BY::ref->{'INACCURATE_TIMES_SINCE'}
Outside this period, postponement of a holidays are not specified and in the strict mode $Date::Holidays::BY::strict=1
throws an exception (croak). But you can be sure of the periodic holidays.
$Date::Holidays::BY::strict
Allows you to throws an exception (croak) if the requested date is outside the determined times. Default is 0.
$Date::Holidays::BY::lang
The language is determined by the locale from $ENV{LANG}
. Allows you to override this language after loading the module.
$Date::Holidays::BY::HOLIDAYS_VALID_SINCE
Deprecated. See $Date::Holidays::BY::ref->{'HOLIDAYS_VALID_SINCE'}
$Date::Holidays::BY::INACCURATE_TIMES_SINCE
Deprecated. See $Date::Holidays::BY::ref->{'INACCURATE_TIMES_BEFORE'}
and $Date::Holidays::BY::ref->{'INACCURATE_TIMES_SINCE'}
FUNCTIONS
holidays( $year )
Returns hash ref of all holidays in the year.
{
MMDD => 'name',
...
}
Сaches the result for the selected language for the specified year in a variable $Date::Holidays::ref->{'cache'}
is_holiday( $year, $month, $day )
Determine whether this date is a BY holiday. Returns holiday name or undef.
is_by_holiday( $year, $month, $day )
Alias for is_holiday().
is_business_day( $year, $month, $day )
Returns true if date is a business day in BY taking holidays and weekends into account.
is_short_business_day( $year, $month, $day )
Returns true if date is a shortened business day.
I18N
Translations are available in Belarusian (be), English (en), and Russian (ru), with the language selected based on the locale from $ENV{LANG}
. If not mapped, "en" is used by default. See $Date::Holidays::BY::lang
.
The module supports localization of holiday names, which can be redefined if needed in $Date::Holidays::BY::ref
:
use Date::Holidays::BY;
$Date::Holidays::BY::ref->{'HOLIDAYS'}->{'0308'}->{'name'}->{'en'} = 'name1';
say Date::Holidays::BY::holidays(2024)->{'0308'}; # name1
$Date::Holidays::BY::ref->{'HOLIDAYS'}->{'0308'}->{'name'}->{'en'} = 'name2';
$Date::Holidays::BY::ref->{'cache'} = undef;
say Date::Holidays::BY::holidays(2024)->{'0308'}; # name2
LICENSE
This software is copyright (c) 2024 by Vladimir Varlamov.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Terms of the Perl programming language system itself
a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License"
AUTHOR
Vladimir Varlamov, <bes.internal@gmail.com>