| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#$Header: /cvsroot/date-chinese/lib/Date/Chinese.pm,v 1.10 2002/08/29 23:43:33 rbowen Exp $ |
|
2
|
|
|
|
|
|
|
package Date::Chinese; |
|
3
|
2
|
|
|
2
|
|
48195
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
87
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
BEGIN { |
|
6
|
2
|
|
|
2
|
|
12
|
use Exporter (); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
41
|
|
|
7
|
2
|
|
|
2
|
|
11
|
use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
296
|
|
|
8
|
2
|
|
|
2
|
|
6
|
$VERSION = (qw'$Revision: 1.12 $')[1]; |
|
9
|
2
|
|
|
|
|
30
|
@ISA = qw (Exporter); |
|
10
|
2
|
|
|
|
|
5
|
@EXPORT = qw ( yearofthe ); |
|
11
|
2
|
|
|
|
|
10
|
@EXPORT_OK = qw (); |
|
12
|
2
|
|
|
|
|
316
|
%EXPORT_TAGS = (); |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Date::Chinese - Calculate dates in the Chinese calendar |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Date::Chinese; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$year = yearofthe( 1999 ); # "Year of the hare, earth" |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Please note that the API of this module is I to change in |
|
28
|
|
|
|
|
|
|
future versions. I'll hopefully be adding more details about the date, |
|
29
|
|
|
|
|
|
|
rather than just the year. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
You should also note that the Chinese new year does not conicide with |
|
32
|
|
|
|
|
|
|
the Gregorian new year, so the determination of what year it is in the |
|
33
|
|
|
|
|
|
|
Chinese calendar is only going to be correct for a portion of the |
|
34
|
|
|
|
|
|
|
Gregorian year. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SUPPORT |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
datetime@perl.org |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 AUTHOR |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Rich Bowen |
|
43
|
|
|
|
|
|
|
CPAN ID: RBOW |
|
44
|
|
|
|
|
|
|
rbowen@rcbowen.com |
|
45
|
|
|
|
|
|
|
http://www.rcbowen.com |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Copyright (c) 2001 Rich Bowen. All rights reserved. |
|
50
|
|
|
|
|
|
|
This program is free software; you can redistribute |
|
51
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
54
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
perl(1). |
|
59
|
|
|
|
|
|
|
http://dates.rcbowen.com/ |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 About the Chinese calendar |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Reference: The Oxford Companion to the Year - Bonnie Blackburn and |
|
64
|
|
|
|
|
|
|
Leofranc Holford-Strevens. Pg 696-707 |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The Chinese calendar is a 19 year cycle. Seven of these 19 years have 13 |
|
67
|
|
|
|
|
|
|
months, and the rest have 12. There's a whole heck of a lot more to it |
|
68
|
|
|
|
|
|
|
than the 12 animals that you see on your placemat at your favorite |
|
69
|
|
|
|
|
|
|
Chinese restaurant. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
There is a cycle of 10 stems and 12 branches. Each stem has associated |
|
72
|
|
|
|
|
|
|
with it an element (wood, fire, earth, metal, water) a yang (fir, |
|
73
|
|
|
|
|
|
|
kindling, hill, weapons, waves) a yin (bamboo, lamp-flame, plain, |
|
74
|
|
|
|
|
|
|
kettle, brooks) a cardinal point (east, south, centre, west, north) |
|
75
|
|
|
|
|
|
|
and a planet (Jupiter, Mars, Saturn, Venus, Mercury). |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Likewise, each branch has associated with it an animal, an element, a |
|
78
|
|
|
|
|
|
|
double-hour, a compass point, and a sign of the zodiac. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Each of these various cycles are going on at the same time, and so |
|
81
|
|
|
|
|
|
|
interact with each other to produce combinations of all of these |
|
82
|
|
|
|
|
|
|
different components. And various combinations mean various things. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
There are, of course, many folks that have more knowledge of how this |
|
85
|
|
|
|
|
|
|
all works than I do. I just used to be a mathematician. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
http://www.math.nus.edu.sg/aslaksen/calendar/chinese.shtml seems like |
|
88
|
|
|
|
|
|
|
a good place to start, but there are many other very informative sites |
|
89
|
|
|
|
|
|
|
on the net. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub yearofthe { |
|
94
|
12
|
|
|
12
|
0
|
27
|
my $year = shift; |
|
95
|
|
|
|
|
|
|
|
|
96
|
12
|
|
|
|
|
22
|
my $cycle = ( $year - 3 )%60; |
|
97
|
|
|
|
|
|
|
|
|
98
|
12
|
|
|
|
|
17
|
my $stem = $cycle % 10; # Not using this right now |
|
99
|
|
|
|
|
|
|
# my @stems = qw(jia yi bing ding wu ji geng xin ren gui); |
|
100
|
12
|
|
|
|
|
37
|
my @stems = qw(wood wood fire fire earth earth metal metal water water); |
|
101
|
12
|
|
|
|
|
15
|
$stem = $stems[$stem-1]; |
|
102
|
|
|
|
|
|
|
|
|
103
|
12
|
|
|
|
|
15
|
my $branch = $cycle % 12; |
|
104
|
|
|
|
|
|
|
# my @branches = qw( zi chou yin mao chen si |
|
105
|
|
|
|
|
|
|
# wu wei shen you xu hai ); |
|
106
|
12
|
|
|
|
|
34
|
my @branches = qw(rat ox tiger hare dragon snake horse |
|
107
|
|
|
|
|
|
|
sheep monkey fowl dog pig ); |
|
108
|
12
|
|
|
|
|
18
|
my $yearofthe = $branches[$branch - 1]; |
|
109
|
|
|
|
|
|
|
|
|
110
|
12
|
|
|
|
|
78
|
return "Year of the $yearofthe, $stem"; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
|
114
|
|
|
|
|
|
|
|