NAME
Date::Holidays - a Date::Holidays::* OOP wrapper
SYNOPSIS
use Date::Holidays;
my $dh = Date::Holidays->new(
countrycode => 'dk'
);
$holidayname = $dh->is_holiday(
year => 2004,
month => 12,
day => 25
);
$hashref = $dh->holidays(
year => 2004
);
$holidays_hashref = $dh->is_holiday(
year => 2004,
month => 12,
day => 25,
countries => ['se', 'dk', 'no'],
);
foreach my $country (keys %{$holidays_hashref}) {
print $holidays_hashref->{$country}."\n";
}
$holidays_hashref = $dh->is_holiday(
year => 2004,
month => 12,
day => 25,
);
DESCRIPTION
These are the methods implemented in this class. They act as wrappers around the different modules implementing different national holidays, and at the same time they provide an OOP interface.
As described below is requires that a certain API is implemented (SEE: holidays and is_holiday below).
If you are an author who wants to comply to this suggestion, either look at some of the other modules in the Date::Holidays::* namespace and Date::Holidays::Abstract - or write me.
new
This is the constructor. It takes the following parameter:
- countrycode (OPTIONAL, see below), two letter unique code representing a country name. Please refer to ISO3166 (or Locale::Country)
The constructor loads the module from Date::Holidays::*, which matches the country code.
holidays
This is a wrapper around the loaded module's holidays method if this is implemented. If this method is not implemented it tries <countrycode>_holidays.
Takes one named argument:
holidays_dt *EXPERIMENTAL*
This method is similar to holidays. It takes one named argument b<year>.
The result is a hashref just as for holidays, but instead the names of the holidays are used as keys and the values are DateTime objects.
is_holiday
This is yet another wrapper around the loaded module's is_holiday method if this is implemented. Also if this method is not implemented it tries is_<countrycode>_holiday.
Takes 3 arguments:
- year, four digit parameter representing year
- month, 1-12, representing month
- day, 1-31, representing day
- countries (OPTIONAL), a list of ISO3166 country codes
is_holiday returns the name of a holiday is present in the country specified by the country code provided to the Date::Holidays constructor.
If however the Date::Holidays object was not provided with a country code, all known countries are tested for a holiday on the specified date, unless the countries parameter specified a subset of countries to test.
In the case where a set of countries are tested the return value from the method is a hashref with the country codes as keys and the values as the result.
- undef if the country has no module or the data could not be obtained
- a name of the holiday if a holiday is present
- an empty string if the a module was located but the day is not a holiday
is_holiday_dt *EXPERIMENTAL*
This method is similar to is_holiday, but instead of 3 separate arguments is only takes a single argument, a DateTime object.
Return 1 for true if the object is a holiday and 0 for false if not.
SEE ALSO
- Date::Holidays::DE
- Date::Holidays::DK
- Date::Holidays::FR
- Date::Holidays::NO
- Date::Holiday::PT
- Date::Holidays::UK
- Date::Japanese::Holiday
- Date::Holidays::Abstract
- Date::Holidays::Super
- DateTime
BUGS
Please report issues via CPAN RT:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Date-Holidays
or by sending mail to
bug-Date-Holidays@rt.cpan.org
ACKNOWLEDGEMENTS
COG (Jose Castro)
RJBS (Ricardo Signes)
MRAMBERG (Marcus Ramberg)
BORUP (Christian Borup)
AUTHOR
Jonas B. Nielsen, (jonasbn) - <jonasbn@cpan.org>
COPYRIGHT
Date-Holidays is (C) by Jonas B. Nielsen, (jonasbn) 2004-2005
Date-Holidays is released under the artistic license
The distribution is licensed under the Artistic License, as specified by the Artistic file in the standard perl distribution (http://www.perl.com/language/misc/Artistic.html).