line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Calendar::Persian; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$Calendar::Persian::VERSION = '0.32'; |
4
|
|
|
|
|
|
|
$Calendar::Persian::AUTHORITY = 'cpan:MANWAR'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Calendar::Persian - Interface to Persian Calendar. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.32 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
|
27032
|
use 5.006; |
|
4
|
|
|
|
|
10
|
|
17
|
4
|
|
|
4
|
|
2522
|
use Data::Dumper; |
|
4
|
|
|
|
|
26662
|
|
|
4
|
|
|
|
|
179
|
|
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
4
|
|
2013
|
use Date::Persian::Simple; |
|
4
|
|
|
|
|
299306
|
|
|
4
|
|
|
|
|
109
|
|
20
|
4
|
|
|
4
|
|
26
|
use Moo; |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
10
|
|
21
|
4
|
|
|
4
|
|
657
|
use namespace::clean; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
12
|
|
22
|
|
|
|
|
|
|
with 'Calendar::Plugin::Renderer'; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
4
|
|
492
|
use overload q{""} => 'as_string', fallback => 1; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
16
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has year => (is => 'rw', predicate => 1); |
27
|
|
|
|
|
|
|
has month => (is => 'rw', predicate => 1); |
28
|
|
|
|
|
|
|
has date => (is => 'ro', default => sub { Date::Persian::Simple->new }); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub BUILD { |
31
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
$self->date->validate_year($self->year) if $self->has_year; |
34
|
0
|
0
|
|
|
|
|
$self->date->validate_month($self->month) if $self->has_month; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
0
|
|
|
|
unless ($self->has_year && $self->has_month) { |
37
|
0
|
|
|
|
|
|
$self->year($self->date->year); |
38
|
0
|
|
|
|
|
|
$self->month($self->date->month); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
The Persian calendar is solar, with the particularity that the year defined by |
45
|
|
|
|
|
|
|
two successive, apparent passages of the Sun through the vernal (spring) |
46
|
|
|
|
|
|
|
equinox. It is based on precise astronomical observations, and moreover uses a |
47
|
|
|
|
|
|
|
sophisticated intercalation system, which makes it more accurate than its younger |
48
|
|
|
|
|
|
|
European counterpart,the Gregorian calendar. It is currently used in Iran as the |
49
|
|
|
|
|
|
|
official calendar of the country. The starting point of the current Iranian |
50
|
|
|
|
|
|
|
calendar is the vernal equinox occurred on Friday March 22 of the year A.D. 622. |
51
|
|
|
|
|
|
|
Persian Calendar for the month of Farvadin year 1390. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
+---------------------------------------------------------------------------------------------------------------+ |
54
|
|
|
|
|
|
|
| Farvardin [1394 BE] | |
55
|
|
|
|
|
|
|
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+ |
56
|
|
|
|
|
|
|
| Yekshanbeh | Doshanbeh | Seshhanbeh | Chaharshanbeh | Panjshanbeh | Jomeh | Shanbeh | |
57
|
|
|
|
|
|
|
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+ |
58
|
|
|
|
|
|
|
| | 1 | |
59
|
|
|
|
|
|
|
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+ |
60
|
|
|
|
|
|
|
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | |
61
|
|
|
|
|
|
|
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+ |
62
|
|
|
|
|
|
|
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | |
63
|
|
|
|
|
|
|
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+ |
64
|
|
|
|
|
|
|
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | |
65
|
|
|
|
|
|
|
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+ |
66
|
|
|
|
|
|
|
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | |
67
|
|
|
|
|
|
|
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+ |
68
|
|
|
|
|
|
|
| 30 | 31 | | |
69
|
|
|
|
|
|
|
+---------------+---------------+---------------+---------------+---------------+---------------+---------------+ |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The package L provides command line tool C to display the |
72
|
|
|
|
|
|
|
supported calendars on the terminal. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SYNOPSIS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
use strict; use warnings; |
77
|
|
|
|
|
|
|
use Calendar::Persian; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# prints current month calendar |
80
|
|
|
|
|
|
|
print Calendar::Persian->new, "\n"; |
81
|
|
|
|
|
|
|
print Calendar::Persian->new->current, "\n"; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# prints persian month calendar for the first month of year 1394. |
84
|
|
|
|
|
|
|
print Calendar::Persian->new({ month => 1, year => 1394 }), "\n"; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# prints persian month calendar in which the given gregorian date falls in. |
87
|
|
|
|
|
|
|
print Calendar::Persian->new->from_gregorian(2015, 1, 14), "\n"; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# prints persian month calendar in which the given julian date falls in. |
90
|
|
|
|
|
|
|
print Calendar::Persian->new->from_julian(2457102.5), "\n"; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# prints current month persian calendar in SVG format. |
93
|
|
|
|
|
|
|
print Calendar::Persian->new->as_svg; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 PERSIAN MONTHS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
+-------+-------------------------------------------------------------------+ |
98
|
|
|
|
|
|
|
| Month | Persian Name | |
99
|
|
|
|
|
|
|
+-------+-------------------------------------------------------------------+ |
100
|
|
|
|
|
|
|
| 1 | Farvardin | |
101
|
|
|
|
|
|
|
| 2 | Ordibehesht | |
102
|
|
|
|
|
|
|
| 3 | Xordad | |
103
|
|
|
|
|
|
|
| 4 | Tir | |
104
|
|
|
|
|
|
|
| 5 | Amordad | |
105
|
|
|
|
|
|
|
| 6 | Sahrivar | |
106
|
|
|
|
|
|
|
| 7 | Mehr | |
107
|
|
|
|
|
|
|
| 8 | Aban | |
108
|
|
|
|
|
|
|
| 9 | Azar | |
109
|
|
|
|
|
|
|
| 10 | Dey | |
110
|
|
|
|
|
|
|
| 11 | Bahman | |
111
|
|
|
|
|
|
|
| 12 | Esfand | |
112
|
|
|
|
|
|
|
+-------+-------------------------------------------------------------------+ |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 PERSIAN DAYS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
+-------+---------------+---------------------------------------------------+ |
117
|
|
|
|
|
|
|
| Index | Persian Name | English Name | |
118
|
|
|
|
|
|
|
+-------+---------------+---------------------------------------------------+ |
119
|
|
|
|
|
|
|
| 0 | Yekshanbeh | Sunday | |
120
|
|
|
|
|
|
|
| 1 | Doshanbeh | Monday | |
121
|
|
|
|
|
|
|
| 2 | Seshhanbeh | Tuesday | |
122
|
|
|
|
|
|
|
| 3 | Chaharshanbeh | Wednesday | |
123
|
|
|
|
|
|
|
| 4 | Panjshanbeh | Thursday | |
124
|
|
|
|
|
|
|
| 5 | Jomeh | Friday | |
125
|
|
|
|
|
|
|
| 6 | Shanbeh | Saturday | |
126
|
|
|
|
|
|
|
+-------+---------------+---------------------------------------------------+ |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
It expects month and year optionally.By default it gets current Persian month and |
131
|
|
|
|
|
|
|
year. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 METHODS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 current() |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns current month of the Persian calendar. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub current { |
142
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
return $self->as_text($self->date->month, $self->date->year); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 from_gregorian($year, $month, $day) |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Returns persian month calendar in which the given gregorian date falls in. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub from_gregorian { |
154
|
0
|
|
|
0
|
1
|
|
my ($self, $year, $month, $day) = @_; |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
return $self->from_julian($self->date->gregorian_to_julian($year, $month, $day)); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 from_julian($julian_date) |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Returns persian month calendar in which the given julian date falls in. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub from_julian { |
166
|
0
|
|
|
0
|
1
|
|
my ($self, $julian_date) = @_; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
my $date = $self->date->from_julian($julian_date); |
169
|
0
|
|
|
|
|
|
return $self->as_text($date->month, $date->year); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 as_svg($month, $year) |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Returns calendar for the given C<$month> and C<$year> rendered in SVG format. If |
175
|
|
|
|
|
|
|
C<$month> and C<$year> missing, it would return current calendar month. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub as_svg { |
180
|
0
|
|
|
0
|
1
|
|
my ($self, $month, $year) = @_; |
181
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
($month, $year) = $self->validate_params($month, $year); |
183
|
0
|
|
|
|
|
|
my $date = Date::Persian::Simple->new({ year => $year, month => $month, day => 1 }); |
184
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
return $self->svg_calendar({ |
186
|
|
|
|
|
|
|
start_index => $date->day_of_week, |
187
|
|
|
|
|
|
|
month_name => $date->get_month_name, |
188
|
|
|
|
|
|
|
days => $date->days_in_month_year($month, $year), |
189
|
|
|
|
|
|
|
year => $year }); |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 as_text($month, $year) |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Returns color coded Persian calendar for the given C<$month> and C<$year>. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub as_text { |
199
|
0
|
|
|
0
|
1
|
|
my ($self, $month, $year) = @_; |
200
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
($month, $year) = $self->validate_params($month, $year); |
202
|
0
|
|
|
|
|
|
my $date = Date::Persian::Simple->new({ year => $year, month => $month, day => 1 }); |
203
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
return $self->text_calendar( |
205
|
|
|
|
|
|
|
{ |
206
|
|
|
|
|
|
|
start_index => $date->day_of_week, |
207
|
|
|
|
|
|
|
month_name => $date->get_month_name, |
208
|
|
|
|
|
|
|
days => $date->days_in_month_year($month, $year), |
209
|
|
|
|
|
|
|
day_names => $date->days, |
210
|
|
|
|
|
|
|
year => $year |
211
|
|
|
|
|
|
|
}); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub as_string { |
215
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
216
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
return $self->as_text($self->month, $self->year); |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
# |
221
|
|
|
|
|
|
|
# |
222
|
|
|
|
|
|
|
# PRIVATE METHODS |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub validate_params { |
225
|
0
|
|
|
0
|
0
|
|
my ($self, $month, $year) = @_; |
226
|
|
|
|
|
|
|
|
227
|
0
|
0
|
0
|
|
|
|
if (defined $month && defined $year) { |
228
|
0
|
|
|
|
|
|
$self->date->validate_month($month); |
229
|
0
|
|
|
|
|
|
$self->date->validate_year($year); |
230
|
|
|
|
|
|
|
|
231
|
0
|
0
|
|
|
|
|
if ($month !~ /^\d+$/) { |
232
|
0
|
|
|
|
|
|
$month = $self->date->get_month_number($month); |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
else { |
236
|
0
|
|
|
|
|
|
$month = $self->month; |
237
|
0
|
|
|
|
|
|
$year = $self->year; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
0
|
|
|
|
|
|
return ($month, $year); |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 AUTHOR |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Mohammad S Anwar, C<< >> |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 REPOSITORY |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
L |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head1 SEE ALSO |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=over 4 |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item L |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=item L |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item L |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=item L |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=back |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head1 BUGS |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, |
268
|
|
|
|
|
|
|
or through the web interface at L. |
269
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your |
270
|
|
|
|
|
|
|
bug as I make changes. |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 SUPPORT |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
perldoc Calendar::Persian |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
You can also look for information at: |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=over 4 |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
L |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
L |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=item * CPAN Ratings |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
L |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=item * Search CPAN |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
L |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=back |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
Copyright (C) 2011 - 2016 Mohammad S Anwar. |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
305
|
|
|
|
|
|
|
the terms of the the Artistic License (2.0). You may obtain a copy of the full |
306
|
|
|
|
|
|
|
license at: |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
L |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified Versions is |
311
|
|
|
|
|
|
|
governed by this Artistic License.By using, modifying or distributing the Package, |
312
|
|
|
|
|
|
|
you accept this license. Do not use, modify, or distribute the Package, if you do |
313
|
|
|
|
|
|
|
not accept this license. |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made by someone |
316
|
|
|
|
|
|
|
other than you,you are nevertheless required to ensure that your Modified Version |
317
|
|
|
|
|
|
|
complies with the requirements of this license. |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service mark, |
320
|
|
|
|
|
|
|
tradename, or logo of the Copyright Holder. |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge patent license |
323
|
|
|
|
|
|
|
to make, have made, use, offer to sell, sell, import and otherwise transfer the |
324
|
|
|
|
|
|
|
Package with respect to any patent claims licensable by the Copyright Holder that |
325
|
|
|
|
|
|
|
are necessarily infringed by the Package. If you institute patent litigation |
326
|
|
|
|
|
|
|
(including a cross-claim or counterclaim) against any party alleging that the |
327
|
|
|
|
|
|
|
Package constitutes direct or contributory patent infringement,then this Artistic |
328
|
|
|
|
|
|
|
License to you shall terminate on the date that such litigation is filed. |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND |
331
|
|
|
|
|
|
|
CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED |
332
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR |
333
|
|
|
|
|
|
|
NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS |
334
|
|
|
|
|
|
|
REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, |
335
|
|
|
|
|
|
|
INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE |
336
|
|
|
|
|
|
|
OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=cut |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
1; # End of Calendar::Persian |