line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Jalali2; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20061
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
5
|
use Exporter; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
45
|
|
6
|
1
|
|
|
1
|
|
935
|
use AutoLoader qw(AUTOLOAD); |
|
1
|
|
|
|
|
3023
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
) ] ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT = qw( |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my @g_days_in_month = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
23
|
|
|
|
|
|
|
my @j_days_in_month = (31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29); |
24
|
|
|
|
|
|
|
my @j_month_name = ("", "Farvardin", "Ordibehesht", "Khordad", "Tir", |
25
|
|
|
|
|
|
|
"Mordad", "Shahrivar", "Mehr", "Aban", "Azar", |
26
|
|
|
|
|
|
|
"Dey", "Bahman", "Esfand"); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Preloaded methods go here. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new { |
31
|
4
|
|
|
4
|
0
|
449
|
my $class = shift; |
32
|
4
|
|
|
|
|
6
|
my ($y,$m,$d,$o)=($_[0],$_[1],$_[2],$_[3]); |
33
|
4
|
100
|
|
|
|
10
|
if(!defined $o) |
34
|
|
|
|
|
|
|
{ |
35
|
2
|
|
|
|
|
4
|
$o=0; |
36
|
|
|
|
|
|
|
} |
37
|
4
|
100
|
|
|
|
11
|
if ($o==0) { |
38
|
3
|
|
|
|
|
5
|
my ($gy,$gm,$gd)=($y-1600,$m-1,$d-1); |
39
|
3
|
|
|
|
|
5
|
my $self={}; |
40
|
3
|
|
|
|
|
3
|
my $i=0; |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
13
|
my $g_day_no = 365*$gy+int(($gy+3)/4)-int(($gy+99)/100)+int(($gy+399)/400); |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
|
|
|
7
|
for ($i=0; $i < $gm; ++$i) { |
45
|
22
|
|
|
|
|
44
|
$g_day_no += $g_days_in_month[$i]; } |
46
|
3
|
100
|
66
|
|
|
25
|
if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0))) { |
|
|
|
33
|
|
|
|
|
47
|
|
|
|
|
|
|
#leap and after Feb |
48
|
1
|
|
|
|
|
2
|
++$g_day_no; } |
49
|
3
|
|
|
|
|
4
|
$g_day_no += $gd; |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
3
|
my $j_day_no = $g_day_no-79; |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
4
|
my $j_np = int($j_day_no/12053); |
54
|
3
|
|
|
|
|
4
|
$j_day_no %= 12053; |
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
|
|
6
|
my $jy = 979+33*$j_np+4*int($j_day_no/1461); |
57
|
|
|
|
|
|
|
|
58
|
3
|
|
|
|
|
4
|
$j_day_no %= 1461; |
59
|
|
|
|
|
|
|
|
60
|
3
|
100
|
|
|
|
8
|
if ($j_day_no >= 366) { |
61
|
2
|
|
|
|
|
4
|
$jy += int(($j_day_no-1)/365); |
62
|
2
|
|
|
|
|
3
|
$j_day_no = ($j_day_no-1)%365; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
66
|
|
|
30
|
for ($i = 0; $i < 11 && $j_day_no >= $j_days_in_month[$i]; ++$i) { |
66
|
13
|
|
|
|
|
50
|
$j_day_no -= $j_days_in_month[$i]; |
67
|
|
|
|
|
|
|
} |
68
|
3
|
|
|
|
|
5
|
my $jm = $i+1; |
69
|
3
|
|
|
|
|
2
|
my $jd = $j_day_no+1; |
70
|
|
|
|
|
|
|
|
71
|
3
|
|
|
|
|
8
|
$self->{jal_day}=$jd; |
72
|
3
|
|
|
|
|
3
|
$self->{jal_month}=$jm; |
73
|
3
|
|
|
|
|
5
|
$self->{jal_year}=$jy; |
74
|
|
|
|
|
|
|
|
75
|
3
|
|
|
|
|
6
|
bless $self; |
76
|
3
|
|
|
|
|
10
|
return $self; |
77
|
|
|
|
|
|
|
} else { |
78
|
1
|
|
|
|
|
2
|
my ($jy,$jm,$jd)=($y-979,$m-1,$d-1); |
79
|
1
|
|
|
|
|
15
|
my $self={}; |
80
|
1
|
|
|
|
|
2
|
my $i=0; |
81
|
1
|
|
|
|
|
4
|
my $j_day_no = 365*$jy + int(($jy/33))*8 + int(($jy%33+3)/4); |
82
|
1
|
|
|
|
|
4
|
for ($i=0; $i < $jm; ++$i) { |
83
|
3
|
|
|
|
|
6
|
$j_day_no += $j_days_in_month[$i]; |
84
|
|
|
|
|
|
|
} |
85
|
1
|
|
|
|
|
1
|
$j_day_no += $jd; |
86
|
1
|
|
|
|
|
4
|
my $g_day_no = $j_day_no+79; |
87
|
1
|
|
|
|
|
3
|
my $gy = 1600 + 400*int(($g_day_no/146097)); #/* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */ |
88
|
1
|
|
|
|
|
2
|
$g_day_no = $g_day_no % 146097; |
89
|
1
|
|
|
|
|
1
|
my $leap = 1; |
90
|
1
|
50
|
|
|
|
5
|
if ($g_day_no >= 36525) #/* 36525 = 365*100 + 100/4 */ |
91
|
|
|
|
|
|
|
{ |
92
|
0
|
|
|
|
|
0
|
$g_day_no--; |
93
|
0
|
|
|
|
|
0
|
$gy += 100*int(($g_day_no/36524)); #/* 36524 = 365*100 + 100/4 - 100/100 */ |
94
|
0
|
|
|
|
|
0
|
$g_day_no = $g_day_no % 36524; |
95
|
0
|
0
|
|
|
|
0
|
if ($g_day_no >= 365) { |
96
|
0
|
|
|
|
|
0
|
$g_day_no++; |
97
|
|
|
|
|
|
|
} else { |
98
|
0
|
|
|
|
|
0
|
$leap = 0; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
1
|
|
|
|
|
3
|
$gy += 4*int(($g_day_no/1461)); #/* 1461 = 365*4 + 4/4 */ |
102
|
1
|
|
|
|
|
1
|
$g_day_no %= 1461; |
103
|
1
|
50
|
|
|
|
4
|
if ($g_day_no >= 366) { |
104
|
0
|
|
|
|
|
0
|
$leap = 0; |
105
|
0
|
|
|
|
|
0
|
$g_day_no--; |
106
|
0
|
|
|
|
|
0
|
$gy += int($g_day_no/365); |
107
|
0
|
|
|
|
|
0
|
$g_day_no = $g_day_no % 365; |
108
|
|
|
|
|
|
|
} |
109
|
1
|
|
66
|
|
|
6
|
for ($i = 0; $g_day_no >= $g_days_in_month[$i] + ($i == 1 && $leap); $i++) { |
110
|
6
|
|
66
|
|
|
28
|
$g_day_no -= $g_days_in_month[$i] + ($i == 1 && $leap); |
111
|
|
|
|
|
|
|
} |
112
|
1
|
|
|
|
|
9
|
my $gm = $i+1; |
113
|
1
|
|
|
|
|
2
|
my $gd = $g_day_no+1; |
114
|
|
|
|
|
|
|
|
115
|
1
|
|
|
|
|
2
|
$self->{jal_day}=$gd; |
116
|
1
|
|
|
|
|
2
|
$self->{jal_month}=$gm; |
117
|
1
|
|
|
|
|
2
|
$self->{jal_year}=$gy; |
118
|
1
|
|
|
|
|
1
|
bless $self; |
119
|
1
|
|
|
|
|
3
|
return $self; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub jal_day { |
126
|
4
|
|
|
4
|
0
|
242
|
my $self = shift; |
127
|
4
|
|
|
|
|
25
|
return ( $self->{jal_day} ); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub jal_month { |
131
|
4
|
|
|
4
|
0
|
6
|
my $self = shift; |
132
|
4
|
|
|
|
|
13
|
return ( $self->{jal_month} ); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub jal_year { |
136
|
4
|
|
|
4
|
0
|
7
|
my $self = shift; |
137
|
4
|
|
|
|
|
14
|
return ( $self->{jal_year} ); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |
144
|
|
|
|
|
|
|
__END__ |