Date::Holidays::Adapter - an adapter class for Date::Holidays::* modules


Date-Holidays documentation  | view source Contained in the Date-Holidays distribution.

Index


NAME

Top

Date::Holidays::Adapter - an adapter class for Date::Holidays::* modules

SYNOPSIS

Top

    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

VERSION

Top

This POD describes version 0.02 of Date::Holidays::Adapter

DESCRIPTION

Top

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.

SUBROUTINES/METHODS

Top

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.

new

The constructor, takes a single named argument, countrycode

is_holiday

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.

holidays

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.

DEVELOPING A DATE::HOLIDAYS::* ADAPTER

Top

If you want to develop an adapter compatible with interface specified in this class. You have to implement the following 3 methods:

new

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.

* holidays

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.

* is_holiday

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

DIAGNOSTICS

Top

* 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).

DEPENDENCIES

Top

* Carp
* Error
* Module::Load
* UNIVERSAL

INCOMPATIBILITIES

Top

Please refer to INCOMPATIBILITIES in Date::Holidays

BUGS AND LIMITATIONS

Top

Please refer to BUGS AND LIMITATIONS in Date::Holidays

BUG REPORTING

Top

Please refer to BUG REPORTING in Date::Holidays

AUTHOR

Top

Jonas B. Nielsen, (jonasbn) - <jonasbn@cpan.org>

LICENSE AND COPYRIGHT

Top


Date-Holidays documentation  | view source Contained in the Date-Holidays distribution.