NAME
App::Dochazka::REST::Util::Holiday - module containing the holidays_in_daterange function
SYNOPSIS
use App::Dochazka::REST::Util::Holiday qw( holidays_in_daterange );
my $holidays1 = holidays_in_daterange(
begin => '2001-01-02',
end => '2001-12-24',
);
my $holidays2 = holidays_in_daterange(
begin => '2001-01-02',
end => '2002-12-24',
);
*WARNING*: holidays_in_daterange()
makes no attempt to validate the date range. It assumes this validation has already taken place, and that the dates are in YYYY-MM-DD format!
EXPORTS
FUNCTIONS
holidays_in_daterange
Given a PARAMHASH containing two properties, begin
and end
, the values of which are canonicalized dates (possibly produced by the split_tsrange()
function), determine the holidays that fall within this range. The function will always return a status object. Upon success, the payload will contain a hashref with the following structure:
{ 'date_range' => { 'begin' => ..., 'end' => ... }, 'holidays' => { ... }, }
where the holidays
hashref will have keys in the format YYYY-MM-DD
, one for each holiday. The idea is that this hash can be used to quickly look up if a given date is a holiday.
is_weekend
Simple function that takes a canonicalized date string in the format YYYY-MM-DD and returns a true or false value indicating whether or not the date falls on a weekend.
get_tomorrow
Given a canonicalized date string in the format YYYY-MM-DD, return the next date (i.e. "tomorrow" from the perspective of the given date).
holidays_and_weekends
Given a date range (same as in holidays_in_daterange
, above), return a reference to a hash of hashes that looks like this (for sample dates):
{
'2015-01-01' => { holiday => 1 },
'2015-01-02' => {},
'2015-01-03' => { weekend => 1 },
'2015-01-04' => { weekend => 1 },
'2015-01-05' => {},
'2015-01-06' => {},
}