line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Converter; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
127195
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
72
|
|
4
|
2
|
|
|
2
|
|
1892
|
use POSIX; |
|
2
|
|
|
|
|
29337
|
|
|
2
|
|
|
|
|
16
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
6754
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1085
|
|
7
|
|
|
|
|
|
|
$VERSION = 1.1; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
1
|
|
|
1
|
0
|
14
|
my ($class, $from, $to) = @_; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
3
|
my $this = {}; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
5
|
$from = ucfirst lc $from; |
15
|
1
|
|
|
|
|
3
|
$to = ucfirst lc $to; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
111
|
eval <
|
|
1
|
|
|
1
|
|
754
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
|
1
|
|
|
|
|
719
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
18
|
|
|
|
|
|
|
use Date::Converter::$from; |
19
|
|
|
|
|
|
|
use Date::Converter::$to; |
20
|
|
|
|
|
|
|
\$this->{to_jed } = \\&Date::Converter::${from}::ymdf_to_jed; |
21
|
|
|
|
|
|
|
\$this->{from_jed} = \\&Date::Converter::${to }::jed_to_ymdf; |
22
|
|
|
|
|
|
|
EVAL |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
25
|
bless $this, $class; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
7
|
return $this; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub convert { |
30
|
1
|
|
|
1
|
0
|
7
|
my ($this, $year, $month, $day) = @_; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
9
|
return $this->{from_jed}($this->{to_jed}($year, $month, $day)); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub y_common_to_astronomical { |
36
|
2
|
|
|
2
|
0
|
3
|
my $y = shift; |
37
|
|
|
|
|
|
|
|
38
|
2
|
50
|
|
|
|
8
|
if ($y < 0) { |
|
|
50
|
|
|
|
|
|
39
|
0
|
|
|
|
|
0
|
return $y + 1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif (!$y) { |
42
|
0
|
|
|
|
|
0
|
return -INT_MAX(); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
2
|
|
|
|
|
14
|
return $y; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub y_astronomical_to_common { |
50
|
100
|
|
|
100
|
0
|
279
|
my $y = shift; |
51
|
|
|
|
|
|
|
|
52
|
100
|
100
|
|
|
|
453
|
return $y <= 0 ? $y - 1 : $y; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub i_modp { |
56
|
1
|
|
|
1
|
0
|
2
|
my ($i, $j) = @_; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
2
|
my $ret = $i % $j; |
59
|
1
|
50
|
|
|
|
3
|
$ret += abs ($j) if $ret < 0; |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
6
|
return $ret; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub i_wrap { |
65
|
0
|
|
|
0
|
0
|
0
|
my ($ival, $ilo, $ihi) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
my $wide = $ihi + 1 - $ilo; |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
0
|
if ($wide == 0) { |
70
|
0
|
|
|
|
|
0
|
return $ilo; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
0
|
|
|
|
|
0
|
return $ilo + i_modp($ival - $ilo, $wide); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |