++ed by:
KEEDI

1 PAUSE user

jonasbn

NAME

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

VERSION

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

SYNOPSIS

    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

DESCRIPTION

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

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

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:

DIAGNOSTICS

DEPENDENCIES

INCOMPATIBILITIES

Please refer to INCOMPATIBILITIES in Date::Holidays

BUGS AND LIMITATIONS

Please refer to BUGS AND LIMITATIONS in Date::Holidays

BUG REPORTING

Please refer to BUG REPORTING in Date::Holidays

AUTHOR

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

LICENSE AND COPYRIGHT

Date::Holidays and related modules are (C) by Jonas B. Nielsen, (jonasbn) 2004-2018

Date-Holidays and related modules are released under the Artistic License 2.0