line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Converter::Republican; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1447
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
4
|
1
|
|
|
1
|
|
7
|
use base 'Date::Converter'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
99
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
144
|
|
7
|
|
|
|
|
|
|
$VERSION = 1.1; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub ymdf_to_jed { |
10
|
0
|
|
|
0
|
0
|
0
|
my ($y, $m, $d, $f) = @_; |
11
|
|
|
|
|
|
|
|
12
|
0
|
0
|
|
|
|
0
|
$f = 0 unless defined $f; |
13
|
|
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
0
|
return -1 if ymd_check(\$y, \$m, \$d); |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
0
|
my ($y_prime, $m_prime, $d_prime, $j1, $j2, $g); |
17
|
|
|
|
|
|
|
{ |
18
|
1
|
|
|
1
|
|
6
|
use integer; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
|
0
|
|
|
|
|
0
|
|
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
$y_prime = $y + 6504 - (13 - $m) / 13; |
21
|
0
|
|
|
|
|
0
|
$m_prime = ($m + 12) % 13; |
22
|
0
|
|
|
|
|
0
|
$d_prime = $d - 1; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
0
|
$j1 = (1461 * $y_prime) / 4; |
25
|
0
|
|
|
|
|
0
|
$j2 = 30 * $m_prime; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
$g = 3 * (($y_prime + 396) / 100) / 4 - 51; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
my $jed = $j1 + $j2 + $d_prime - 111 - $g - 0.5; |
31
|
0
|
|
|
|
|
0
|
$jed += $f; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
return $jed; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub jed_to_ymdf { |
37
|
13
|
|
|
13
|
0
|
9222
|
my ($jed) = @_; |
38
|
|
|
|
|
|
|
|
39
|
13
|
|
|
|
|
28
|
my $j = int ($jed + 0.5); |
40
|
13
|
|
|
|
|
23
|
my $f = ($jed + 0.5) - $j; |
41
|
|
|
|
|
|
|
|
42
|
13
|
|
|
|
|
16
|
my ($g, $j_prime, $y_prime, $t_prime, $m_prime, $d_prime, $y, $m, $d); |
43
|
|
|
|
|
|
|
{ |
44
|
1
|
|
|
1
|
|
169
|
use integer; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
|
13
|
|
|
|
|
16
|
|
45
|
|
|
|
|
|
|
|
46
|
13
|
|
|
|
|
23
|
$g = 3 * ((4 * $j + 578797) / 146097) / 4 - 51; |
47
|
13
|
|
|
|
|
16
|
$j_prime = $j + 111 + $g; |
48
|
|
|
|
|
|
|
|
49
|
13
|
|
|
|
|
20
|
$y_prime = (4 * $j_prime + 3) / 1461; |
50
|
13
|
|
|
|
|
18
|
$t_prime = ((4 * $j_prime + 3) % 1461) / 4; |
51
|
13
|
|
|
|
|
12
|
$m_prime = $t_prime / 30; |
52
|
13
|
|
|
|
|
13
|
$d_prime = $t_prime % 30; |
53
|
|
|
|
|
|
|
|
54
|
13
|
|
|
|
|
15
|
$d = $d_prime + 1; |
55
|
13
|
|
|
|
|
14
|
$m = ($m_prime % 13) + 1; |
56
|
13
|
|
|
|
|
23
|
$y = $y_prime - 6504 + (13 - $m) / 13; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
13
|
|
|
|
|
113
|
return ($y, $m, $d, $f); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub ymd_check { |
63
|
0
|
|
|
0
|
0
|
|
my ($y_ref, $m_ref, $d_ref) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
return 1 if $$y_ref <= 0; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
return 1 if ym_check($y_ref, $m_ref); |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
day_borrow($y_ref, $m_ref, $d_ref); |
70
|
0
|
|
|
|
|
|
day_carry($y_ref, $m_ref, $d_ref); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return 0; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub ym_check { |
76
|
0
|
|
|
0
|
0
|
|
my ($y_ref, $m_ref) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
return 1 if y_check($y_ref); |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
month_borrow($y_ref, $m_ref); |
81
|
0
|
|
|
|
|
|
month_carry($y_ref, $m_ref); |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
return 0; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub y_check { |
87
|
0
|
|
|
0
|
0
|
|
my ($y_ref) = @_; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return !($$y_ref > 0); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub month_borrow { |
93
|
0
|
|
|
0
|
0
|
|
my ($y_ref, $m_ref) = @_; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
while ($$m_ref <= 0) { |
96
|
0
|
|
|
|
|
|
$$m_ref += year_length_months($$y_ref); |
97
|
0
|
|
|
|
|
|
$$y_ref--; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub month_carry { |
102
|
0
|
|
|
0
|
0
|
|
my ($y_ref, $m_ref) = @_; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my $months = year_length_months($$y_ref); |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
return if $$m_ref <= $months; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
$$m_ref -= $months; |
109
|
0
|
|
|
|
|
|
$$y_ref++; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub day_borrow { |
113
|
0
|
|
|
0
|
0
|
|
my ($y_ref, $m_ref, $d_ref) = @_; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
while ($$d_ref <= 0) { |
116
|
0
|
|
|
|
|
|
$$m_ref--; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
month_borrow($y_ref, $m_ref); |
119
|
0
|
|
|
|
|
|
$$d_ref += month_length($$y_ref, $$m_ref); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub day_carry { |
124
|
0
|
|
|
0
|
0
|
|
my ($y_ref, $m_ref, $d_ref) = @_; |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
my $days = month_length($$y_ref, $$m_ref); |
127
|
0
|
|
|
|
|
|
my $months = year_length_months($$y_ref); |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
while ($$d_ref > $days) { |
130
|
0
|
|
|
|
|
|
$$d_ref -= $days; |
131
|
0
|
|
|
|
|
|
$$m_ref++; |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
$days = month_length($$y_ref, $$m_ref); |
134
|
0
|
|
|
|
|
|
month_carry($$y_ref, $$m_ref); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub year_length_months { |
139
|
|
|
|
|
|
|
# my $y = shift; |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
0
|
0
|
|
return 13; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub month_length { |
145
|
0
|
|
|
0
|
0
|
|
my ($y, $m) = @_; |
146
|
|
|
|
|
|
|
|
147
|
0
|
0
|
|
|
|
|
return 0 if ym_check(\$y, \$m); |
148
|
|
|
|
|
|
|
|
149
|
0
|
0
|
0
|
|
|
|
if (1 <= $m && $m <= 12) { |
|
|
0
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
return 30; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
elsif ($m == 13) { |
153
|
0
|
0
|
|
|
|
|
if (year_is_leap($y)) { |
154
|
0
|
|
|
|
|
|
return 6; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
else { |
157
|
0
|
|
|
|
|
|
return 5; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub year_is_leap { |
163
|
0
|
|
|
0
|
0
|
|
my $y = shift; |
164
|
|
|
|
|
|
|
|
165
|
0
|
0
|
|
|
|
|
return 0 if y_check($y); |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
my $ret = 0; |
168
|
|
|
|
|
|
|
|
169
|
0
|
0
|
|
|
|
|
if (($y + 1) % 4 == 0) { |
170
|
0
|
|
|
|
|
|
$ret = 1; |
171
|
0
|
0
|
|
|
|
|
if (($y + 1) % 100 == 0) { |
172
|
0
|
|
|
|
|
|
$ret = 0; |
173
|
0
|
0
|
|
|
|
|
if (($y + 1) % 400 == 0) { |
174
|
0
|
|
|
|
|
|
$ret = 1; |
175
|
0
|
0
|
|
|
|
|
if (($y + 1) % 4000 == 0) { |
176
|
0
|
|
|
|
|
|
$ret = 0; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
return $ret; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
1; |