Date::Holidays::Adapter - an adapter class for Date::Holidays::* modules
my $adapter = Date::Holidays::Adapter->new(countrycode => 'NO'); my ($year, $month, $day) = (localtime)[ 5, 4, 3 ]; $year += 1900; $month += 1; print "Woohoo" if $adapter->is_holiday( year => $year, month => $month, day => $day ); my $hashref = $adapter->holidays(year => $year); printf "Dec. 24th is named '%s'\n", $hashref->{'1224'}; #christmas I hope
This POD describes version 0.02 of Date::Holidays::Adapter
The is the SUPER adapter class. All of the adapters in the distribution of Date::Holidays are subclasses of this class. (SEE also Date::Holidays).
The SUPER adapter class is at the same time a generic adapter. It attempts to adapt to the most used API for modules in the Date::Holidays::* namespace. So it should only be necessary to implement adapters to the exceptions to modules not following the the defacto standard or suffering from other local implementations.
The public methods in this class are all expected from the adapter, so it actually corresponds with the abstract is outlined in Date::Holidays::Abstract.
Not all methods/subroutines may be implemented in the adaptee classes, the adapters attempt to make the adaptee APIs adaptable where possible. This is afterall the whole idea of the Adapter Pattern, but apart from making the single Date::Holidays::* modules uniform towards the clients and Date::Holidays it is attempted to make the multitude of modules uniform in the extent possible.
The constructor, takes a single named argument, countrycode
The holidays method, takes 3 named arguments, year, month and day
returns an indication of whether the day is a holiday in the calendar of the country referenced by countrycode in the call to the constructor new.
The holidays method, takes a single named argument, year
returns a reference to a hash holding the calendar of the country referenced by countrycode in the call to the constructor new.
The calendar will spand for a year and the keys consist of month and day concatenated.
If you want to develop an adapter compatible with interface specified in this class. You have to implement the following 3 methods:
A constructor, taking a single argument a two-letter countrycode (SEE: Locale::Country)
You can also inherit the one implemented and offered by this class
NBIf inheritance is used, please remember to overwrite the two following methods, if applicable.
This has to follow the API outlined in SUBROUTINES/METHODS.
For the adaptee class anything goes, hence the use of an adapter.
Please refer to the DEVELOPER section in Date::Holidays about contributing to the Date::Holidays::* namespace or attempting for adaptability with Date::Holidays.
Apart from the methods described above you can also overwrite the _fetch method in this class, This is used if your module is not a part of the Date::Holidays::* namespace or the module bears a name which is not ISO3166 compliant.
See also:
Date::Holidays::UK
Date::Japanese::Holiday
Date::Holidays::Exception::AdapterLoad
Exception thrown in the case where the _load method is unable to load a requested adapter module.
The exception is however handled internally.
Date::Holidays::Exception::AdapterInitialization
Exception thrown in the case where the _new method is unable to initialize a requested adapter module.
Date::Holidays::Exception::UnsupportedMethod
Exception thrown in the case where the loaded and initialized module does not support the called method. (SEE: METHODS/SUBROUTINES).
Carp
Error
Module::Load
UNIVERSAL
Please refer to INCOMPATIBILITIES in Date::Holidays
Please refer to BUGS AND LIMITATIONS in Date::Holidays
Please refer to BUG REPORTING in Date::Holidays
Jonas B. Nielsen, (jonasbn) - <jonasbn@cpan.org>
<jonasbn@cpan.org>
Date::Holidays and related modules are (C) by Jonas B. Nielsen, (jonasbn) 2004-2007
Date::Holidays and related modules are 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).
To install Date::Holidays, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Date::Holidays
CPAN shell
perl -MCPAN -e shell install Date::Holidays
For more information on module installation, please visit the detailed CPAN module installation guide.