Date-Holidays-CN

 view release on metacpan or  search on metacpan

lib/Date/Holidays/CN.pm  view on Meta::CPAN

use base 'Exporter';
use vars qw/$VERSION @EXPORT @EXPORT_OK/;
$VERSION = '0.01';
@EXPORT = qw(is_cn_holiday cn_holidays);
@EXPORT_OK = qw(is_cn_solar_holiday is_cn_lunar_holiday);

use DateTime;
use DateTime::Calendar::Chinese;
use Time::Local;

# The Gregorian calendar/solar calendar
my $SOLAR = {
	'0101' => '元旦',
	'0214' => '情人节',
	'0308' => '妇女节',
	'0312' => '植树节',
	'0401' => '愚人节',
	'0405' => '清明节',
	'0501' => '劳动节',
	'0504' => '青年节',
	'0601' => '劳动节',
	'0701' => '建党日',
	'0801' => '建军节',
	'0910' => '教师节',
	'1001' => '国庆节',
	'1225' => '圣诞节',
};	

# The Chinese calendar/lunar calendar
my $LUNAR = {
	'0101' => '春节',
	'0115' => '元宵节',
	'0505' => '端午节',
	'0707' => '七夕情人节',
	'0815' => '中秋节',
	'0909' => '重阳节',
	'1208' => '腊八节',
	'1222' => '冬至节',
	'1230' => '除夕',

lib/Date/Holidays/CN.pm  view on Meta::CPAN

}

sub is_cn_holiday {
	is_cn_solar_holiday(@_) || is_cn_lunar_holiday(@_);
}

sub cn_holidays {
	my ($year) = @_;
	defined $year  || return undef;

	# only provide solar calendar for now
	return $SOLAR;
}

1;
__END__
=encoding utf8

=head1 NAME

Date::Holidays::CN - Determine Chinese public holidays

lib/Date/Holidays/CN.pm  view on Meta::CPAN

	my $is_holiday = is_cn_lunar_holiday( 2005, 9, 18 ); # $day = '中秋节'

=head1 EXPORT

=head2 is_cn_holiday( $year, $month, $day )

determine whether that day is a Chinese holiday

=head2 cn_holidays($year)

BE CAREFUL! It only provide solar calendar for now! And it's not suggested!

=head1 EXPORT_OK

SUGGESTED! quicker and more elegant!

=head2 is_cn_solar_holiday( $year, $month, $day )

determine whether that day is a Chinese holiday by the Gregorian calendar/solar calendar

=head2 is_cn_lunar_holiday( $year, $month, $day )

determine whether that day is a Chinese holiday by the Chinese calendar/lunar calendar

=head1 RETURN VALUE

if it is a holiday, return the Chinese holiday name(utf8), otherwise return undef.

=head1 AUTHOR

Fayland Lam, C<< <fayland at gmail.com> >>

=head1 COPYRIGHT & LICENSE



( run in 0.586 second using v1.01-cache-2.11-cpan-5dc5da66d9d )