line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Calendar::Saka; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$Calendar::Saka::VERSION = '1.34'; |
4
|
|
|
|
|
|
|
$Calendar::Saka::AUTHORITY = 'cpan:MANWAR'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Calendar::Saka - Interface to Indian Calendar. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 1.34 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
|
28635
|
use 5.006; |
|
4
|
|
|
|
|
13
|
|
17
|
4
|
|
|
4
|
|
2411
|
use Data::Dumper; |
|
4
|
|
|
|
|
30125
|
|
|
4
|
|
|
|
|
256
|
|
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
4
|
|
2026
|
use Date::Saka::Simple; |
|
4
|
|
|
|
|
338150
|
|
|
4
|
|
|
|
|
116
|
|
20
|
4
|
|
|
4
|
|
27
|
use Moo; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
12
|
|
21
|
4
|
|
|
4
|
|
704
|
use namespace::clean; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
16
|
|
22
|
|
|
|
|
|
|
with 'Calendar::Plugin::Renderer'; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
4
|
|
543
|
use overload q{""} => 'as_string', fallback => 1; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
27
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has year => (is => 'rw', predicate => 1); |
27
|
|
|
|
|
|
|
has month => (is => 'rw', predicate => 1); |
28
|
|
|
|
|
|
|
has date => (is => 'ro', default => sub { Date::Saka::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
|
|
|
|
|
|
|
Module to play with Saka calendar mostly used in the South indian, Goa and |
45
|
|
|
|
|
|
|
Maharashatra. It supports the functionality to add / minus days, months and years |
46
|
|
|
|
|
|
|
to a Saka date. It can also converts Saka date to Gregorian/Julian date. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
The Saka eras are lunisolar calendars, and feature annual cycles of twelve lunar |
49
|
|
|
|
|
|
|
months, each month divided into two phases: the 'bright half' (shukla) and the |
50
|
|
|
|
|
|
|
'dark half' (krishna); these correspond respectively to the periods of the |
51
|
|
|
|
|
|
|
'waxing' and the 'waning' of the moon. Thus, the period beginning from the first |
52
|
|
|
|
|
|
|
day after the new moon and ending on the full moon day constitutes the shukla |
53
|
|
|
|
|
|
|
paksha or 'bright half' of the month the period beginning from the day after the |
54
|
|
|
|
|
|
|
full moon until & including the next new moon day constitutes the krishna paksha |
55
|
|
|
|
|
|
|
or 'dark half' of the month. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
The "year zero" corresponds to 78 BCE in the Saka calendar. The Saka calendar |
58
|
|
|
|
|
|
|
begins with the month of Chaitra (March) and the Ugadi/Gudi Padwa festivals mark |
59
|
|
|
|
|
|
|
the new year. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Each month in the Shalivahana calendar begins with the 'bright half' and is |
62
|
|
|
|
|
|
|
followed by the 'dark half'. Thus, each month of the Shalivahana calendar ends |
63
|
|
|
|
|
|
|
with the no-moon day and the new month begins on the day after that. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
A variant of the Saka Calendar was reformed & standardized as the Indian National |
66
|
|
|
|
|
|
|
calendar in 1957. This official calendar follows the Shalivahan Shak calendar in |
67
|
|
|
|
|
|
|
beginning from the month of Chaitra and counting years with 78 CE being year zero. |
68
|
|
|
|
|
|
|
It features a constant number of days in every month with leap years.Saka Calendar |
69
|
|
|
|
|
|
|
for the month of Chaitra year 1937 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
+----------------------------------------------------------------------------------------------------------------------+ |
72
|
|
|
|
|
|
|
| Chaitra [1937 BE] | |
73
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+----------------+----------------+----------------+ |
74
|
|
|
|
|
|
|
| Ravivara | Somvara | Mangalavara | Budhavara | Brahaspativara | Sukravara | Sanivara | |
75
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+----------------+----------------+----------------+ |
76
|
|
|
|
|
|
|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | |
77
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+----------------+----------------+----------------+ |
78
|
|
|
|
|
|
|
| 8 | 9 | 10 | 11 | 12 | 13 | 14 | |
79
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+----------------+----------------+----------------+ |
80
|
|
|
|
|
|
|
| 15 | 16 | 17 | 18 | 19 | 20 | 21 | |
81
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+----------------+----------------+----------------+ |
82
|
|
|
|
|
|
|
| 22 | 23 | 24 | 25 | 26 | 27 | 28 | |
83
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+----------------+----------------+----------------+ |
84
|
|
|
|
|
|
|
| 29 | 30 | | |
85
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+----------------+----------------+----------------+ |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The package L provides command line tool C to display the |
88
|
|
|
|
|
|
|
supported calendars on the terminal. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SYNOPSIS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
use strict; use warnings; |
93
|
|
|
|
|
|
|
use Calendar::Saka; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# prints current saka month calendar. |
96
|
|
|
|
|
|
|
print Calendar::Saka->new->current, "\n"; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# prints saka month calendar in which the given gregorian date falls in. |
99
|
|
|
|
|
|
|
print Calendar::Saka->new->from_gregorian(2015, 4, 19), "\n"; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# prints saka month calendar in which the given julian date falls in. |
102
|
|
|
|
|
|
|
print Calendar::Saka->new->from_julian(2457102.5), "\n"; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# prints current month saka calendar in SVG format. |
105
|
|
|
|
|
|
|
print Calendar::Saka->new->as_svg; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# prints current month saka calendar in text format. |
108
|
|
|
|
|
|
|
print Calendar::Saka->new->as_text; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SAKA MONTHS |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
+-------+-------------------------------------------------------------------+ |
113
|
|
|
|
|
|
|
| Order | Name | |
114
|
|
|
|
|
|
|
+-------+-------------------------------------------------------------------+ |
115
|
|
|
|
|
|
|
| 1 | Chaitra | |
116
|
|
|
|
|
|
|
| 2 | Vaisakha | |
117
|
|
|
|
|
|
|
| 3 | Jyaistha | |
118
|
|
|
|
|
|
|
| 4 | Asadha | |
119
|
|
|
|
|
|
|
| 5 | Sravana | |
120
|
|
|
|
|
|
|
| 6 | Bhadra | |
121
|
|
|
|
|
|
|
| 7 | Asvina | |
122
|
|
|
|
|
|
|
| 8 | Kartika | |
123
|
|
|
|
|
|
|
| 9 | Agrahayana | |
124
|
|
|
|
|
|
|
| 10 | Pausa | |
125
|
|
|
|
|
|
|
| 11 | Magha | |
126
|
|
|
|
|
|
|
| 12 | Phalguna | |
127
|
|
|
|
|
|
|
+-------+-------------------------------------------------------------------+ |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 SAKA DAYS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
+---------+-----------+-----------------------------------------------------+ |
132
|
|
|
|
|
|
|
| Weekday | Gregorian | Saka | |
133
|
|
|
|
|
|
|
+---------+-----------+-----------------------------------------------------+ |
134
|
|
|
|
|
|
|
| 0 | Sunday | Ravivara | |
135
|
|
|
|
|
|
|
| 1 | Monday | Somvara | |
136
|
|
|
|
|
|
|
| 2 | Tuesday | Mangalavara | |
137
|
|
|
|
|
|
|
| 3 | Wednesday | Budhavara | |
138
|
|
|
|
|
|
|
| 4 | Thursday | Brahaspativara | |
139
|
|
|
|
|
|
|
| 5 | Friday | Sukravara | |
140
|
|
|
|
|
|
|
| 6 | Saturday | Sanivara | |
141
|
|
|
|
|
|
|
+---------+-----------+-----------------------------------------------------+ |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 METHODS |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 current() |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Returns current month of the Saka calendar. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub current { |
152
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
return $self->as_text($self->date->month, $self->date->year); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 from_gregorian() |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Returns saka month calendar in which the given gregorian date falls in. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub from_gregorian { |
164
|
0
|
|
|
0
|
1
|
|
my ($self, $year, $month, $day) = @_; |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
return $self->from_julian($self->date->gregorian_to_julian($year, $month, $day)); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 from_julian($julian_date) |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Returns saka month calendar in which the given julian date falls in. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub from_julian { |
176
|
0
|
|
|
0
|
1
|
|
my ($self, $julian) = @_; |
177
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
my $date = $self->from_julian($julian); |
179
|
0
|
|
|
|
|
|
return $self->as_text($date->month, $date->year); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 as_svg($month, $year) |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Returns calendar for the given C<$month> and C<$year> rendered in SVG format. If |
185
|
|
|
|
|
|
|
C<$month> and C<$year> missing, it would return current calendar month. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub as_svg { |
190
|
0
|
|
|
0
|
1
|
|
my ($self, $month, $year) = @_; |
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
($month, $year) = $self->validate_params($month, $year); |
193
|
0
|
|
|
|
|
|
my $date = Date::Saka::Simple->new({ year => $year, month => $month, day => 1 }); |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
return $self->svg_calendar( |
196
|
|
|
|
|
|
|
{ |
197
|
|
|
|
|
|
|
start_index => $date->day_of_week, |
198
|
|
|
|
|
|
|
month_name => $date->get_month_name, |
199
|
|
|
|
|
|
|
days => $date->days_in_month_year($month, $year), |
200
|
|
|
|
|
|
|
year => $year |
201
|
|
|
|
|
|
|
}); |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head2 as_text($month, $year) |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Returns color coded Saka calendar for the given C<$month> and C<$year>. If |
207
|
|
|
|
|
|
|
C<$month> and C<$year> missing, it would return current calendar month. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=cut |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub as_text { |
212
|
0
|
|
|
0
|
1
|
|
my ($self, $month, $year) = @_; |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
($month, $year) = $self->validate_params($month, $year); |
215
|
0
|
|
|
|
|
|
my $date = Date::Saka::Simple->new({ year => $year, month => $month, day => 1 }); |
216
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
return $self->text_calendar( |
218
|
|
|
|
|
|
|
{ |
219
|
|
|
|
|
|
|
start_index => $date->day_of_week, |
220
|
|
|
|
|
|
|
month_name => $date->get_month_name, |
221
|
|
|
|
|
|
|
days => $date->days_in_month_year($month, $year), |
222
|
|
|
|
|
|
|
day_names => $date->days, |
223
|
|
|
|
|
|
|
year => $year |
224
|
|
|
|
|
|
|
}); |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub as_string { |
228
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
229
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
return $self->as_text($self->month, $self->year); |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 AUTHOR |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Mohammad S Anwar, C<< >> |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 REPOSITORY |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
L |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 BUGS |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, |
244
|
|
|
|
|
|
|
or through the web interface at L. |
245
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your |
246
|
|
|
|
|
|
|
bug as I make changes. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 SUPPORT |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
perldoc Calendar::Saka |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
You can also look for information at: |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=over 4 |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
L |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
L |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=item * CPAN Ratings |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
L |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=item * Search CPAN |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
L |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=back |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Copyright (C) 2011 - 2016 Mohammad S Anwar. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
281
|
|
|
|
|
|
|
the terms of the the Artistic License (2.0). You may obtain a copy of the full |
282
|
|
|
|
|
|
|
license at: |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
L |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified Versions is |
287
|
|
|
|
|
|
|
governed by this Artistic License.By using, modifying or distributing the Package, |
288
|
|
|
|
|
|
|
you accept this license. Do not use, modify, or distribute the Package, if you do |
289
|
|
|
|
|
|
|
not accept this license. |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made by someone |
292
|
|
|
|
|
|
|
other than you,you are nevertheless required to ensure that your Modified Version |
293
|
|
|
|
|
|
|
complies with the requirements of this license. |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service mark, |
296
|
|
|
|
|
|
|
tradename, or logo of the Copyright Holder. |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge patent license |
299
|
|
|
|
|
|
|
to make, have made, use, offer to sell, sell, import and otherwise transfer the |
300
|
|
|
|
|
|
|
Package with respect to any patent claims licensable by the Copyright Holder that |
301
|
|
|
|
|
|
|
are necessarily infringed by the Package. If you institute patent litigation |
302
|
|
|
|
|
|
|
(including a cross-claim or counterclaim) against any party alleging that the |
303
|
|
|
|
|
|
|
Package constitutes direct or contributory patent infringement,then this Artistic |
304
|
|
|
|
|
|
|
License to you shall terminate on the date that such litigation is filed. |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND |
307
|
|
|
|
|
|
|
CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED |
308
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR |
309
|
|
|
|
|
|
|
NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS |
310
|
|
|
|
|
|
|
REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, |
311
|
|
|
|
|
|
|
INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE |
312
|
|
|
|
|
|
|
OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=cut |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
1; # End of Calendar::Saka |