DateTime-Calendar-Chinese
view release on metacpan or search on metacpan
0.05 - 28 Jun 2005
- Fix Build.PL create_makefile_pl to create 'traditional' Makefile.PL
- Update dependency (require newer modules). This fixes problems reported
by Dave Rolsky where make test fails.
- Slightly modify test
0.04 - 30 Jan 2004
- Was missing the time_zone() method, which makes a difference when
you pass a DT::C::Chinese to a from_object() method for other
calendards
- Add test
0.03 - 24 Jan 2004
- It's good to be able to access CVS.
- Added methods to get the Chinese year name, as well as just the
celestial stem or the terrestrial branch. Dave Rolsky.
- Added a method to return the zodiac animal for the year. Dave Rolsky.
0.02 - 24 Jan 2004
[ The "Darn, Astronomical Calendars Are Hard" Release ]
lib/DateTime/Calendar/Chinese.pm view on Meta::CPAN
$dt->cycle_year; # 1 - 60
$dt->month; # 1-12
$dt->leap_month; # true/false
$dt->day; # 1-30
$dt->elapsed_years; # years since "Chinese Epoch"
my ($rd_days, $rd_secs, $rd_nanosecs) = $dt->utc_rd_values();
=head1 DESCRIPTION
This is an implementation of the Chinese calendar as described in
"Calendrical Calculations" [1]. Please note that the following description
is the description from [1], and the author has not made attempts to verify
the correctness of statements with other sources.
The Chinese calendar described in [1] is expressed in terms of "cycle",
"cycle_year", "month", "a boolean leap_month", and "day".
Traditional Chinese years have been counted using the "Sexagecimal Cycle
of Names", which is a cycle of 60 names for each year. The names are
the combination of a "celestial stem" (tian1 gan1), with a "terrestrial branch"
(di4 zhi1):
Celestial Stems Terrestrial Branches
------------------- -----------------------
| Jia3 | | Zi (Rat) |
xt/01_extended.t view on Meta::CPAN
subtest $file => sub {
my %koyomi = do $file;
foreach my $date ( sort keys %koyomi ) {
if ($date !~ /^(\d{4})-(\d{2})-(\d{2})$/) {
die "Bad date: $date";
}
my $dt = DateTime->new(year => int($1), month => int($2), day => int($3), time_zone => 'Asia/Tokyo');
my $ch = DateTime::Calendar::Chinese->from_object( object => $dt );
ok $ch, "created chinese calendar for $date";
my $data = $koyomi{$date};
if ($data->{kyuureki} !~ /^(\d{4})-(\d{2})-(\d{2})$/) {
die "Bad date: $data->{kyuureki}";
}
my ($ch_y, $ch_m, $ch_d) = (int($1), int($2), int($3));
# XXX we store the year as a cycle of 60 years, but the original
# data does not reflect that.
( run in 0.591 second using v1.01-cache-2.11-cpan-5dc5da66d9d )