Date::Holidays::NO - A wrapper for No::Dato to comply with Date::Holidays


Date-Holidays-NO documentation Contained in the Date-Holidays-NO distribution.

Index


Code Index:

NAME

Top

Date::Holidays::NO - A wrapper for No::Dato to comply with Date::Holidays

SYNOPSIS

Top

use Date::Holidays;

my $dh = Date::Holidays->new( countrycode => 'no' );

$dh->is_holiday( 2004, 12, 25); $dh->holidays( $year );

DESCRIPTION

Top

This is just a wrapper around No::Dato to comply with the Date::Holidays factory class. See Date::Holidays for usage information, and No::Dato for implementation details.

METHODS

Top

holidays

takes a year, and returns a hashref of all the holidays for that year.

is_holiday

Takes year/month/date as parameters, and returns the name of the holiday if it's a holiday, or undef otherwise.

BUGS

Top

Please report issues via CPAN RT:

  http://rt.cpan.org/NoAuth/Bugs.html?Dist=Date-Holidays-NO

or by sending mail to

  bug-Date-Holidays-NO@rt.cpan.org

AUTHOR

Top

Marcus Ramberg, (mramberg) - <mramberg@cpan.org>

COPYRIGHT

Top


Date-Holidays-NO documentation Contained in the Date-Holidays-NO distribution.

package Date::Holidays::NO;

use vars qw($VERSION);

$VERSION=0.2;

use base qw(Date::Holidays::Abstract);
use No::Dato qw(helligdag helligdager);

sub holidays {
	my $year=shift;
	my @days=helligdager($year);
	my %days;
	foreach my $day (@days) {
		my ($month,$day, $text)=$day=~m/\d{4}-(\d{2})-(\d{2})\s*(.*)$/;
		$days{"$month$day"}=$text
	}
	return \%days;
};

sub is_holiday {
	my ($year,$month,$day)=@_;
	$month=($month<10 ?"0".$month : $month); 
	$day=($day<10 ?"0".$day :$day); 
	my $holiday=helligdag("$year-$month-$day");
	return $holiday if $holiday;
	return undef;
};

1;

__END__