App::Dochazka::REST::Holiday - non-database holiday and date routines
use App::Dochazka::REST::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!
holidays_in_daterange()
Given a canonicalized tsrange, return the number of hours. For example, if the range is [ 2016-01-06 08:00, 2016-01-06 09:00 ), the return value will be 1. If the range is [ 2016-01-06 08:00, 2016-01-07 09:00 ), the return value will 25.
Returns 0 if there's a problem with the tsrange argument.
Compute difference (in days) between two canonical dates
Takes canonical date YYYY-MM-DD and returns $y, $m, $d
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:
begin
end
split_tsrange()
{ '2015-01-01' => '', '2015-05-01' => '', }
The idea is that this hash can be used to quickly look up if a given date is a holiday.
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.
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).
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):
holidays_in_daterange
{ '2015-01-01' => { holiday => 1 }, '2015-01-02' => {}, '2015-01-03' => { weekend => 1 }, '2015-01-04' => { weekend => 1 }, '2015-01-05' => {}, '2015-01-06' => {}, }
Note that the range is always considered inclusive -- i.e. the bounding dates of the range will be included in the hash.
Takes a string that might be a canonicalized tsrange. Attempts to extract beginning and ending dates (YYYY-MM-DD) from it. If this succeeds, an OK status object is returned, the payload of which is a hash suitable for passing to holidays_and_weekends().
Takes $y, $m, $d and returns canonical date YYYY-MM-DD
To install App::Dochazka::REST, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Dochazka::REST
CPAN shell
perl -MCPAN -e shell install App::Dochazka::REST
For more information on module installation, please visit the detailed CPAN module installation guide.