line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Indic::Chandramana; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id$ |
4
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
149879
|
use warnings; |
|
14
|
|
|
|
|
20
|
|
|
14
|
|
|
|
|
473
|
|
6
|
14
|
|
|
14
|
|
60
|
use strict; |
|
14
|
|
|
|
|
20
|
|
|
14
|
|
|
|
|
315
|
|
7
|
14
|
|
|
14
|
|
51
|
use Carp qw/ carp croak /; |
|
14
|
|
|
|
|
19
|
|
|
14
|
|
|
|
|
804
|
|
8
|
14
|
|
|
|
|
1401
|
use DateTime::Indic::Utils qw/ epoch sidereal_year sidereal_month |
9
|
|
|
|
|
|
|
lunar_on_or_before newmoon saura_rashi saura_varsha solar_longitude |
10
|
|
|
|
|
|
|
tithi_at_dt |
11
|
14
|
|
|
14
|
|
5754
|
/; |
|
14
|
|
|
|
|
36
|
|
12
|
14
|
|
|
14
|
|
16926
|
use DateTime::Event::Sunrise; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use DateTime::Util::Calc qw/ amod dt_from_moment mod search_next /; |
14
|
|
|
|
|
|
|
use Params::Validate qw/ validate BOOLEAN SCALAR OBJECT UNDEF /; |
15
|
|
|
|
|
|
|
use POSIX qw/ floor /; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
DateTime::Indic::Chandramana - Base class for Indian luni-solar calendars |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 VERSION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Version 0.2 |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our $VERSION = '0.2'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This class is meant to be subclassed not used directly. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 ABSTRACT |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
A module that implements an Indian chandramAna (luni-solar,) nirAyana |
36
|
|
|
|
|
|
|
(sidereal,) khagolasiddha (heliocentric,) and spaShTa (based on the true times |
37
|
|
|
|
|
|
|
of astronomical events) calendar. The calendar described in this module isn't |
38
|
|
|
|
|
|
|
actually used as-is though; rather it is a basis for actual Indian luni-solar |
39
|
|
|
|
|
|
|
calendars which are implemented in other modules in the L |
40
|
|
|
|
|
|
|
collection. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my @varsha_nama = qw{ prabhava vibhava shukla pramoda prajApati a~ngirA |
45
|
|
|
|
|
|
|
shrImukha bhAva yuvA dhAtA ishvara bahudhAnya pramAthI vikrama vR^isha |
46
|
|
|
|
|
|
|
chitrabhAnu subhAnu tAraNa pArthiva vyaya sarvajit sarvadhArI virodhI |
47
|
|
|
|
|
|
|
vikrti khara nandana vijaya jaya manmatha durmukha hemalambi vilambi |
48
|
|
|
|
|
|
|
vikArI shArvarI plava shubhakrta shobhana krodhI vishvavAsu parAbhava |
49
|
|
|
|
|
|
|
plava~nga kIlaka saumya sAdharaNa virodhakrta paridhAvi pramAdi Ananda |
50
|
|
|
|
|
|
|
rAkshasa anala pi~Ngala kAlayukta siddhArthi raudra durmati dundubhi |
51
|
|
|
|
|
|
|
rudhirodgArI raktAkShI krodhana kshaya |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my @vara_nama = qw{ |
55
|
|
|
|
|
|
|
ravivAra somavAra ma~ngalavAra budhavAra guruvAra shukravAra shanivAra |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my @vara_abbrev = qw { ra so ma bu gu shu sha }; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my @masa_nama = qw{ |
61
|
|
|
|
|
|
|
chaitra vaishAkha jyeShTa AShADha shrAvaNa bhAdrapada ashvina kArtika |
62
|
|
|
|
|
|
|
mArgashIrasa pauSha mAgha phAlguna |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my @masa_abbrev = qw{ |
66
|
|
|
|
|
|
|
chai vai jye AshA shrA bhA a kA mAr pau mA phA |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my @paksha_nama = qw{shukla kR^iShNa}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my @paksha_abbrev = qw{shu kR^i}; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $adhika_nama = 'adhika'; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $adhika_abbrev = 'a'; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my @tithi_nama = qw{ |
78
|
|
|
|
|
|
|
pratipadA dvitIyA tR^itIya chaturthI paMchamI ShaShTI saptamI aShTamI |
79
|
|
|
|
|
|
|
navamI dashamI ekAdashI dvAdashI trayodashI chaturdashI |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my @tithi_abbrev = qw{ |
83
|
|
|
|
|
|
|
pra dvi tR^i cha paM Sha sa a na da e dvA tra chada |
84
|
|
|
|
|
|
|
}; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $amavasya_nama = 'amAvAsyA'; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $amavasya_abbrev = 'a'; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $purnima_nama = 'pUrNimA'; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $purnima_abbrev = 'pU'; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DESCRIPTION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Note: In this document, Sanskrit words are transliterated using the ITRANS |
97
|
|
|
|
|
|
|
scheme. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 The Year (varSha) |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
All chandramAna calendars have as their epoch, the first day of the current |
102
|
|
|
|
|
|
|
kali yuga which is equivalent to Friday, January 23, -3101 BC in the proleptic |
103
|
|
|
|
|
|
|
Gregorian calendar. sidereal years (the time it takes for the sun to make one |
104
|
|
|
|
|
|
|
pass through the entire zodiac) and days are counted off from this date to |
105
|
|
|
|
|
|
|
perform calculations but the actual calendars in use, employ different eras to |
106
|
|
|
|
|
|
|
number years. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 The Lunar Month (mAsa) |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
chandramAna calendars consists of 12 lunar months (mAsa). A mAsa is defined as |
111
|
|
|
|
|
|
|
one complete phase cycle of the Moon. Some calendars use amAsanta mAsa which |
112
|
|
|
|
|
|
|
end on the day of the new moon. Others use pUrNimAnta mAsa which end on the |
113
|
|
|
|
|
|
|
day of the full moon. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The Sanskrit names of the mAsa and their approximate correspondence to |
116
|
|
|
|
|
|
|
Western months are: |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1 chaitra (March-April) 7 ashvina (September-October) |
119
|
|
|
|
|
|
|
2 vaishAkha (April-May) 8 kArtika (October-November) |
120
|
|
|
|
|
|
|
3 jyeShTa (May-June) 9 mArgashIrasa (November-December) |
121
|
|
|
|
|
|
|
4 AShADha (June-July) 10 pauSha (December-January) |
122
|
|
|
|
|
|
|
5 shrAvaNa (July-August) 11 mAgha (January-February) |
123
|
|
|
|
|
|
|
6 bhAdrapada (August-September) 12 phAlguna (February-March) |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Some calendars start from a mAsa other than chaitra. Nevertheless chaitra |
126
|
|
|
|
|
|
|
would still be considered the "first" month despite not being the first month |
127
|
|
|
|
|
|
|
of the year. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 Leap and Omitted mAsa (adhikamAsa and kShayamAsa) |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Because 12 mAsa can be a little bit more or less than a sidereal year, it is |
132
|
|
|
|
|
|
|
sometimes necessary to add or subtract a mAsa to keep the two synchronized. |
133
|
|
|
|
|
|
|
When the Sun spends an entire mAsa without entering another zodiacal sign, |
134
|
|
|
|
|
|
|
the mAsa is called adhika ("leap") and it has the same name as the following |
135
|
|
|
|
|
|
|
month. Very rarely, when the Sun enters two zodiacal signs in what would have |
136
|
|
|
|
|
|
|
been one mAsa, it is kShaya (omitted altogether.) |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 Waxing and Waning Halves (pakSha) |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Each masa is divided into two halves. The shuklapakSha ("bright part") is |
141
|
|
|
|
|
|
|
when the Moon is waxing, culminating in the full moon. The kR^iShNapakSha |
142
|
|
|
|
|
|
|
("dark half") is when the Moon is waning, culminating in the new moon. |
143
|
|
|
|
|
|
|
Therefore in a pUrNimAnta mAsa, the kR^ishNapakSha is first, followed by the |
144
|
|
|
|
|
|
|
shuklapakSha, whereas in an amAsanta mAsa, the shuklapakSha is first, followed |
145
|
|
|
|
|
|
|
by the kR^iShNapakSha. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 Lunar Day (tithi) |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Each pakSha consists of tithis which are equivalent to a 12 degree increments |
150
|
|
|
|
|
|
|
of increase or decrease in the phase of the Moon. The tithis of each pakSha |
151
|
|
|
|
|
|
|
are named and numbered as follows: |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
1 pratipadA ("beginning") |
154
|
|
|
|
|
|
|
2 dvitIyA ("2nd") |
155
|
|
|
|
|
|
|
3 tR^itIya ("3rd") |
156
|
|
|
|
|
|
|
4 chaturthI ("4th") |
157
|
|
|
|
|
|
|
5 paMchamI ("5th") |
158
|
|
|
|
|
|
|
6 ShaShTI ("6th") |
159
|
|
|
|
|
|
|
7 saptamI ("7th") |
160
|
|
|
|
|
|
|
8 aShTamI ("8th") |
161
|
|
|
|
|
|
|
9 navamI ("9th") |
162
|
|
|
|
|
|
|
10 dashamI ("10th") |
163
|
|
|
|
|
|
|
11 ekAdashI ("11th") |
164
|
|
|
|
|
|
|
12 dvAdashI ("12th") |
165
|
|
|
|
|
|
|
13 trayodashI ("13th") |
166
|
|
|
|
|
|
|
14 chaturdashI ("14th") |
167
|
|
|
|
|
|
|
15 pUrNimA ("full moon") |
168
|
|
|
|
|
|
|
30 amAvasya ("new moon") |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
The tithi of a particular day is the one that prevails at sunrise on that day. |
171
|
|
|
|
|
|
|
(This is called the uditatithi.) |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 Leap and Omitted tithi (adhikatithi and kShayatithi) |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Because the orbital speed of the Moon is not constant, sometimes a tithi can |
176
|
|
|
|
|
|
|
start and end entirely within one day. In that case it is called a |
177
|
|
|
|
|
|
|
kShayatithi and it is omitted from the calendar. Other times, one tithi |
178
|
|
|
|
|
|
|
stretches over two sunrises. This is called a vR^iddha ("large") tithi. In |
179
|
|
|
|
|
|
|
this case, both days have the same number and name. The first is prefixed |
180
|
|
|
|
|
|
|
adhika or "leap". |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 Solar Day (vAra) |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
The Indian day does not start after midnight but at sunrise. The period |
185
|
|
|
|
|
|
|
from sunrise to sunset is called ahasa ("day") and the period from sunset to |
186
|
|
|
|
|
|
|
the next sunrise is called rAtra ("night.") Together they make one ahorAtra or |
187
|
|
|
|
|
|
|
vAra. Each vAra has a name in a seven-day cycle. Thr Sanskrit names of the |
188
|
|
|
|
|
|
|
vAra are: |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
1 ravivAra ("day of the Sun" i.e. Sunday) |
191
|
|
|
|
|
|
|
2 somavAra ("day of the Moon" i.e. Monday) |
192
|
|
|
|
|
|
|
3 ma~ngalavAra ("day of Mars" i.e. Tuesday) |
193
|
|
|
|
|
|
|
4 budhavAra ("day of Mercury" i.e. Wednesday) |
194
|
|
|
|
|
|
|
5 guruvAra ("day of Jupiter" i.e. Thursday) |
195
|
|
|
|
|
|
|
6 shukravAra ("day of Venus" i.e. Friday) |
196
|
|
|
|
|
|
|
7 shanivAra ("day of Saturn" i.e. Saturday) |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 Latitude, Longitude, and Avantika |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
In order to know the correct chandramAna date, you have to know the time of |
201
|
|
|
|
|
|
|
sunrise and this varies depending on where on Earth you are. In this module |
202
|
|
|
|
|
|
|
we use the modern geospatial coordinate system where the prime meridian passing |
203
|
|
|
|
|
|
|
through Greenwich is 0 degrees longitude and the equator is 0 degrees latitude. |
204
|
|
|
|
|
|
|
However traditionally the temple of mahAkAla (Shiva as the embodiment of Time) |
205
|
|
|
|
|
|
|
in Avantika (modern Ujjain, Madhya Pradesh) was considered the prime meridian. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 METHODS |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head2 DATETIME METHODS |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
These methods are either required by the L API or copied from it. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head3 new (%args) |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Constructs a new instance of this class. The following arguments can be given: |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=over 4 |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=item * varsha |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
The numeric year according to the calender's era. Defaults to 0. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item * masa |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
The mAsa (lunar month) as a number from 1 to 12. Defaults to 1. See |
226
|
|
|
|
|
|
|
L for the month corresponding to each number. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item * adhikamasa |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
1 if this is an adhikamAsa (leap month), 0 otherwise. Defaults to 0. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * paksha |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
1 if this is the kR^iShNapakSha (waning half) of a mAsa, 0 if it is the |
235
|
|
|
|
|
|
|
shuklapakSha (waxing half.) Defaults to 0. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item * tithi |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
The numeric tithi (lunar day) expressed as a number from 1 to 14 or by |
240
|
|
|
|
|
|
|
convention, 15 for the pUrNimA (full moon) and 30 for the amAvAsya (new moon.) |
241
|
|
|
|
|
|
|
Defaults to 1. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item * adhikatithi |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
1 if this is an adhika (leap) tithi, 0 otherwise. Defaults to 0. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item * latitude |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
The latitude of the point for which the date is to be calculated |
250
|
|
|
|
|
|
|
expressed as decimal degrees. Negative values are used for latitudes south of |
251
|
|
|
|
|
|
|
the equator so the allowable range for this argument is from -180 to 180. |
252
|
|
|
|
|
|
|
Defaults to 23.15, the latitude of avantika. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=item * longitude |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
The longitude of the point for which the panchanga is to be calculated |
257
|
|
|
|
|
|
|
expressed as decimal degrees. Negative values are used for longitudes west of |
258
|
|
|
|
|
|
|
Greenwich so the allowable range for this argument is from -180 to 180. |
259
|
|
|
|
|
|
|
Defaults to 75.76, the longitude of avantika. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=item * time_zone |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Time zone for which the panchanga is to be calculated. It can either be a |
264
|
|
|
|
|
|
|
timezone name accepted by L or a L |
265
|
|
|
|
|
|
|
object. Defaults to 'Asia/Kolkata' (Indian Standard Time.) |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=back |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=cut |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
## no critic 'ProhibitConstantPragma' |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
sub new { |
274
|
|
|
|
|
|
|
my ( $class, @arguments ) = @_; |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
my %args = validate( |
277
|
|
|
|
|
|
|
@arguments, |
278
|
|
|
|
|
|
|
{ |
279
|
|
|
|
|
|
|
varsha => { |
280
|
|
|
|
|
|
|
type => SCALAR, |
281
|
|
|
|
|
|
|
default => 0, |
282
|
|
|
|
|
|
|
}, |
283
|
|
|
|
|
|
|
masa => { |
284
|
|
|
|
|
|
|
type => SCALAR, |
285
|
|
|
|
|
|
|
default => 1, |
286
|
|
|
|
|
|
|
callbacks => { |
287
|
|
|
|
|
|
|
'between 1 and 12' => sub { ( $_[0] > 0 && $_[0] < 13 ) }, |
288
|
|
|
|
|
|
|
}, |
289
|
|
|
|
|
|
|
}, |
290
|
|
|
|
|
|
|
adhikamasa => { |
291
|
|
|
|
|
|
|
type => BOOLEAN, |
292
|
|
|
|
|
|
|
default => 0, |
293
|
|
|
|
|
|
|
callbacks => |
294
|
|
|
|
|
|
|
{ '0 or 1' => sub { ( $_[0] == 0 || $_[0] == 1 ) }, }, |
295
|
|
|
|
|
|
|
}, |
296
|
|
|
|
|
|
|
paksha => { |
297
|
|
|
|
|
|
|
type => BOOLEAN, |
298
|
|
|
|
|
|
|
default => 0, |
299
|
|
|
|
|
|
|
callbacks => |
300
|
|
|
|
|
|
|
{ '0 or 1' => sub { ( $_[0] == 0 || $_[0] == 1 ) }, }, |
301
|
|
|
|
|
|
|
}, |
302
|
|
|
|
|
|
|
tithi => { |
303
|
|
|
|
|
|
|
type => SCALAR, |
304
|
|
|
|
|
|
|
default => 1, |
305
|
|
|
|
|
|
|
callbacks => { |
306
|
|
|
|
|
|
|
'between 1 and 14, or 15 or 30' => sub { |
307
|
|
|
|
|
|
|
( $_[0] > 0 && $_[0] < 15 ) |
308
|
|
|
|
|
|
|
|| $_[0] == 15 |
309
|
|
|
|
|
|
|
|| $_[0] == 30; |
310
|
|
|
|
|
|
|
}, |
311
|
|
|
|
|
|
|
}, |
312
|
|
|
|
|
|
|
}, |
313
|
|
|
|
|
|
|
adhikatithi => { |
314
|
|
|
|
|
|
|
type => BOOLEAN, |
315
|
|
|
|
|
|
|
default => 0, |
316
|
|
|
|
|
|
|
callbacks => |
317
|
|
|
|
|
|
|
{ '0 or 1' => sub { ( $_[0] == 0 || $_[0] == 1 ) }, }, |
318
|
|
|
|
|
|
|
}, |
319
|
|
|
|
|
|
|
latitude => { |
320
|
|
|
|
|
|
|
type => SCALAR, |
321
|
|
|
|
|
|
|
default => '23.15', |
322
|
|
|
|
|
|
|
callbacks => { |
323
|
|
|
|
|
|
|
'between -180 and 180' => |
324
|
|
|
|
|
|
|
sub { ( $_[0] >= -180 && $_[0] < 180 ) }, |
325
|
|
|
|
|
|
|
}, |
326
|
|
|
|
|
|
|
}, |
327
|
|
|
|
|
|
|
longitude => { |
328
|
|
|
|
|
|
|
type => SCALAR, |
329
|
|
|
|
|
|
|
default => '75.76', |
330
|
|
|
|
|
|
|
callbacks => { |
331
|
|
|
|
|
|
|
'between -180 and 180' => |
332
|
|
|
|
|
|
|
sub { ( $_[0] >= -180 && $_[0] < 180 ) }, |
333
|
|
|
|
|
|
|
}, |
334
|
|
|
|
|
|
|
}, |
335
|
|
|
|
|
|
|
time_zone => { |
336
|
|
|
|
|
|
|
type => SCALAR | OBJECT, |
337
|
|
|
|
|
|
|
default => 'Asia/Kolkata', # Indian Standard Time |
338
|
|
|
|
|
|
|
}, |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
); |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
my $self = bless \%args, $class; |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
$self->{lunar_day} = |
345
|
|
|
|
|
|
|
( $self->{paksha} == 1 && $self->{tithi} < 30 ) |
346
|
|
|
|
|
|
|
? $self->{tithi} + 15 |
347
|
|
|
|
|
|
|
: $self->{tithi}; |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
$self->{sun} = DateTime::Event::Sunrise->new( |
350
|
|
|
|
|
|
|
latitude => $self->{latitude}, |
351
|
|
|
|
|
|
|
longitude => $self->{longitude}, |
352
|
|
|
|
|
|
|
altitude => 0, |
353
|
|
|
|
|
|
|
); |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
( $self->{rd_days}, $self->{rd_secs}, $self->{rd_nanosecs} ) = |
356
|
|
|
|
|
|
|
$self->_fixed_from_lunar; |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
$self->{vara} = amod( $self->{rd_days} - epoch - 1, 7 ); |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
return $self; |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
sub _fixed_from_lunar { |
364
|
|
|
|
|
|
|
my ($self) = @_; |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
my $approx = |
367
|
|
|
|
|
|
|
epoch + |
368
|
|
|
|
|
|
|
sidereal_year * ( $self->{varsha} + $self->_era + $self->{masa} / 12.0 ); |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
if ( $self->{masa} < $self->_masa_offset ) { |
371
|
|
|
|
|
|
|
$approx += sidereal_year; |
372
|
|
|
|
|
|
|
} |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
my $s = floor( |
375
|
|
|
|
|
|
|
$approx - ( 1.0 / 360.0 ) * sidereal_year * ( |
376
|
|
|
|
|
|
|
mod( |
377
|
|
|
|
|
|
|
solar_longitude( |
378
|
|
|
|
|
|
|
dt_from_moment($approx)->set_time_zone( $self->{time_zone} ) |
379
|
|
|
|
|
|
|
->jd |
380
|
|
|
|
|
|
|
) - $self->{masa} * 30 + 180, |
381
|
|
|
|
|
|
|
360 |
382
|
|
|
|
|
|
|
) - 180 |
383
|
|
|
|
|
|
|
) |
384
|
|
|
|
|
|
|
); |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
my $k = |
387
|
|
|
|
|
|
|
tithi_at_dt( dt_from_moment( $s + ( 1.0 / 4.0 ) ) |
388
|
|
|
|
|
|
|
->set_time_zone( $self->{time_zone} ) ); |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
my $x; |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
my $mid = $self->_lunar_from_fixed( |
393
|
|
|
|
|
|
|
dt_from_moment( $s - 15 )->set_time_zone( $self->{time_zone} ), |
394
|
|
|
|
|
|
|
$self->{sun} ); |
395
|
|
|
|
|
|
|
if ( |
396
|
|
|
|
|
|
|
$mid->{masa} < $self->{masa} |
397
|
|
|
|
|
|
|
|| ( $mid->{adhikamasa} |
398
|
|
|
|
|
|
|
&& !$self->{adhikamasa} ) |
399
|
|
|
|
|
|
|
) |
400
|
|
|
|
|
|
|
{ |
401
|
|
|
|
|
|
|
$x = mod( $k + 15, 30 ) - 15; |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
else { |
404
|
|
|
|
|
|
|
$x = mod( $k - 15, 30 ) + 15; |
405
|
|
|
|
|
|
|
} |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
my $est = $s + $self->{lunar_day} - $x; |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
my $tau = $est - mod( |
410
|
|
|
|
|
|
|
tithi_at_dt( |
411
|
|
|
|
|
|
|
dt_from_moment( $est + ( 1.0 / 4.0 ) ) |
412
|
|
|
|
|
|
|
->set_time_zone( $self->{time_zone} ) |
413
|
|
|
|
|
|
|
) - $self->{lunar_day} + 15, |
414
|
|
|
|
|
|
|
30 |
415
|
|
|
|
|
|
|
) + 15; |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
my $date = dt_from_moment($tau)->set_time_zone( $self->{time_zone} ); |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
search_next( |
420
|
|
|
|
|
|
|
base => $date, |
421
|
|
|
|
|
|
|
check => sub { |
422
|
|
|
|
|
|
|
return lunar_on_or_before( $self, |
423
|
|
|
|
|
|
|
$self->_lunar_from_fixed( $_[0], $self->{sun}, ), |
424
|
|
|
|
|
|
|
); |
425
|
|
|
|
|
|
|
}, |
426
|
|
|
|
|
|
|
next => sub { $_[0]->add( days => 1 ); }, |
427
|
|
|
|
|
|
|
); |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
return $date->utc_rd_values; |
430
|
|
|
|
|
|
|
} |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
sub _lunar_from_fixed { |
433
|
|
|
|
|
|
|
my ( $self, $dt, $sun ) = @_; |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
my $result = {}; |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
my $suryodaya = |
438
|
|
|
|
|
|
|
$sun->sunrise_datetime($dt)->set_time_zone( $dt->time_zone ); |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
$result->{lunar_day} = tithi_at_dt($suryodaya); |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
# adhikatithi |
443
|
|
|
|
|
|
|
my $last_suryodaya = |
444
|
|
|
|
|
|
|
$sun->sunrise_datetime( $dt->clone->subtract( days => 1 ) ); |
445
|
|
|
|
|
|
|
$result->{adhikatithi} = |
446
|
|
|
|
|
|
|
( $result->{lunar_day} == tithi_at_dt($last_suryodaya) ) ? 1 : 0; |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
# paksha and normalize tithi number |
449
|
|
|
|
|
|
|
$result->{paksha} = 0; |
450
|
|
|
|
|
|
|
$result->{tithi} = $result->{lunar_day}; |
451
|
|
|
|
|
|
|
if ( $result->{tithi} > 15 ) { |
452
|
|
|
|
|
|
|
$result->{paksha} = 1; |
453
|
|
|
|
|
|
|
if ( $result->{tithi} != 30 ) { |
454
|
|
|
|
|
|
|
$result->{tithi} -= 15; |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
# masa and adhikamasa |
459
|
|
|
|
|
|
|
my $pnm = newmoon( $suryodaya->jd, 0 ); |
460
|
|
|
|
|
|
|
my $nnm = newmoon( $suryodaya->jd, 1 ); |
461
|
|
|
|
|
|
|
my $solarmonth = saura_rashi($pnm); |
462
|
|
|
|
|
|
|
my $nextsolarmonth = saura_rashi($nnm); |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
$result->{masa} = amod( $solarmonth + 1, 12 ); |
465
|
|
|
|
|
|
|
$result->{adhikamasa} = ( $solarmonth == $nextsolarmonth ) ? 1 : 0; |
466
|
|
|
|
|
|
|
if ( $self->_purnimanta |
467
|
|
|
|
|
|
|
&& $result->{adhikamasa} == 0 |
468
|
|
|
|
|
|
|
&& $result->{paksha} == 1 ) |
469
|
|
|
|
|
|
|
{ |
470
|
|
|
|
|
|
|
$result->{masa} = amod( $result->{masa} + 1, 12 ); |
471
|
|
|
|
|
|
|
} |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
# varsha |
474
|
|
|
|
|
|
|
if ( $result->{masa} <= ( $self->_purnimanta ? 2 : 1 ) ) { |
475
|
|
|
|
|
|
|
$result->{varsha} = |
476
|
|
|
|
|
|
|
saura_varsha( $suryodaya->clone->add( days => 180 ) ); |
477
|
|
|
|
|
|
|
} |
478
|
|
|
|
|
|
|
else { |
479
|
|
|
|
|
|
|
$result->{varsha} = saura_varsha($suryodaya); |
480
|
|
|
|
|
|
|
} |
481
|
|
|
|
|
|
|
$result->{varsha} -= $self->_era; |
482
|
|
|
|
|
|
|
if ( $result->{masa} < $self->_masa_offset ) { |
483
|
|
|
|
|
|
|
$result->{varsha}--; |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
return $result; |
487
|
|
|
|
|
|
|
} |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
=head3 clone |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
Returns a copy of the object. |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=cut |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
sub clone { |
496
|
|
|
|
|
|
|
my ($self) = @_; |
497
|
|
|
|
|
|
|
return bless { %{$self} }, ref $self; |
498
|
|
|
|
|
|
|
} |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=head3 from_object |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
Builds a C object from another I |
503
|
|
|
|
|
|
|
object. This function takes the following parameters: |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
=over 4 |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=item * object |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
a DateTime API compatible object. (Basically this means it supports |
510
|
|
|
|
|
|
|
L.) This parameter is required. |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=item * latitude |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
The latitude of the point for which the date is to be calculated |
515
|
|
|
|
|
|
|
expressed as decimal degrees. Negative values are used for latitudes south of |
516
|
|
|
|
|
|
|
the equator so the allowable range for this argument is from -180 to 180. |
517
|
|
|
|
|
|
|
Defaults to 23.15, the latitude of avantika. |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
=item * longitude |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
The longitude of the point for which the panchanga is to be calculated |
522
|
|
|
|
|
|
|
expressed as decimal degrees. Negative values are used for longitudes west of |
523
|
|
|
|
|
|
|
Greenwich so the allowable range for this argument is from -180 to 180. |
524
|
|
|
|
|
|
|
Defaults to 75.76, the longitude of avantika. |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
=back |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
=cut |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
sub from_object { |
531
|
|
|
|
|
|
|
my ( $class, @arguments ) = @_; |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
my %args = validate( |
534
|
|
|
|
|
|
|
@arguments, |
535
|
|
|
|
|
|
|
{ |
536
|
|
|
|
|
|
|
object => { |
537
|
|
|
|
|
|
|
type => OBJECT, |
538
|
|
|
|
|
|
|
can => 'utc_rd_values', |
539
|
|
|
|
|
|
|
}, |
540
|
|
|
|
|
|
|
latitude => { |
541
|
|
|
|
|
|
|
type => SCALAR, |
542
|
|
|
|
|
|
|
default => '23.15', # lat. of Avantika |
543
|
|
|
|
|
|
|
callbacks => { |
544
|
|
|
|
|
|
|
'between -180 and 180' => |
545
|
|
|
|
|
|
|
sub { ( $_[0] >= -180 && $_[0] < 180 ) }, |
546
|
|
|
|
|
|
|
}, |
547
|
|
|
|
|
|
|
}, |
548
|
|
|
|
|
|
|
longitude => { |
549
|
|
|
|
|
|
|
type => SCALAR, |
550
|
|
|
|
|
|
|
default => '75.76', # long. of Avantika |
551
|
|
|
|
|
|
|
callbacks => { |
552
|
|
|
|
|
|
|
'between -180 and 180' => |
553
|
|
|
|
|
|
|
sub { ( $_[0] >= -180 && $_[0] < 180 ) }, |
554
|
|
|
|
|
|
|
}, |
555
|
|
|
|
|
|
|
}, |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
# locale => { |
558
|
|
|
|
|
|
|
# type => SCALAR | OBJECT | UNDEF, |
559
|
|
|
|
|
|
|
# default => undef, |
560
|
|
|
|
|
|
|
# }, |
561
|
|
|
|
|
|
|
} |
562
|
|
|
|
|
|
|
); |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
my $sun = DateTime::Event::Sunrise->new( |
565
|
|
|
|
|
|
|
latitude => $args{latitude}, |
566
|
|
|
|
|
|
|
longitude => $args{longitude}, |
567
|
|
|
|
|
|
|
altitude => 0, |
568
|
|
|
|
|
|
|
); |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
my $results = $class->_lunar_from_fixed( $args{object}, $sun, ); |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
my $newobj = $class->new( |
573
|
|
|
|
|
|
|
varsha => $results->{varsha}, |
574
|
|
|
|
|
|
|
masa => $results->{masa}, |
575
|
|
|
|
|
|
|
adhikamasa => $results->{adhikamasa}, |
576
|
|
|
|
|
|
|
paksha => $results->{paksha}, |
577
|
|
|
|
|
|
|
tithi => $results->{tithi}, |
578
|
|
|
|
|
|
|
adhikatithi => $results->{adhikatithi}, |
579
|
|
|
|
|
|
|
latitude => $args{latitude}, |
580
|
|
|
|
|
|
|
longitude => $args{longitude}, |
581
|
|
|
|
|
|
|
time_zone => $args{object}->time_zone, |
582
|
|
|
|
|
|
|
); |
583
|
|
|
|
|
|
|
return $newobj; |
584
|
|
|
|
|
|
|
} |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
=head3 strftime(@formats) |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
This function takes one or more parameters consisting of strings |
589
|
|
|
|
|
|
|
containing special specifiers. For each such string it will return a |
590
|
|
|
|
|
|
|
string formatted according to the specifiers, er, specified. The following |
591
|
|
|
|
|
|
|
specifiers are allowed in the format string: |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
=over 4 |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=item * %a Equivalent to L. |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=item * %A Equivalent to L. |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=item * %l Equivalent to L. |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
=item * %L Equivalent to L. |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
=item * %m Equivalent to L. |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
=item * %M Equivalent to L. |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
=item * %p Equivalent to L. |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=item * %P Equivalent to L. |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
=item * %t Equivalent to L. |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
=item * %T Equivalent to L. |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
=item * %v Equivalent to L. |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
=item * %V Equivalent to L. |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=item * %w Equivalent to L. |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
=item * %x Equivalent to '%y %A %M %P %L %w' |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
=item * %y Equivalent to L. |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
=item * %% A literal `%' character. |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
=back |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
Any method name may be specified using the format C<%{method}> name |
630
|
|
|
|
|
|
|
where "method" is a valid C object method. |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=cut |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
my %formats = ( |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
'a' => sub { $_[0]->adhikamasa_abbrev }, |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
'A' => sub { $_[0]->adhikamasa_name }, |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
'l' => sub { $_[0]->adhikatithi_abbrev }, |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
'L' => sub { $_[0]->adhikatithi_name }, |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
'm' => sub { $_[0]->masa_abbrev }, |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
'M' => sub { $_[0]->masa_name }, |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
'p' => sub { $_[0]->paksha_abbrev }, |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
'P' => sub { $_[0]->paksha_name }, |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
't' => sub { $_[0]->tithi_abbrev }, |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
'T' => sub { $_[0]->tithi_name }, |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
'v' => sub { $_[0]->vara_abbrev }, |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
'V' => sub { $_[0]->vara_name }, |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
'w' => sub { $_[0]->tithi }, |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
'x' => sub { |
663
|
|
|
|
|
|
|
join q{}, |
664
|
|
|
|
|
|
|
( |
665
|
|
|
|
|
|
|
$_[0]->varsha . q{ }, |
666
|
|
|
|
|
|
|
$_[0]->adhikamasa ? ( $_[0]->adhikamasa_name . q{ } ) : q{}, |
667
|
|
|
|
|
|
|
$_[0]->masa_name . q{ }, |
668
|
|
|
|
|
|
|
$_[0]->paksha_name . q{ }, |
669
|
|
|
|
|
|
|
$_[0]->adhikatithi ? ( $_[0]->adhikatithi_name . q{ } ) : q{}, |
670
|
|
|
|
|
|
|
$_[0]->tithi, |
671
|
|
|
|
|
|
|
); |
672
|
|
|
|
|
|
|
}, |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
'y' => sub { $_[0]->varsha }, |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
'%' => sub { q{%} }, ## no critic 'ProhibitNoisyQuotes' |
677
|
|
|
|
|
|
|
); |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
sub strftime { |
680
|
|
|
|
|
|
|
my $self = shift; |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
# make a copy or caller's scalars get munged |
683
|
|
|
|
|
|
|
my @formats = @_; |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
my @r; |
686
|
|
|
|
|
|
|
foreach my $f (@formats) { |
687
|
|
|
|
|
|
|
$f =~ s/ |
688
|
|
|
|
|
|
|
( |
689
|
|
|
|
|
|
|
?: |
690
|
|
|
|
|
|
|
%{(\w+)} # method name like %{day_name} |
691
|
|
|
|
|
|
|
| |
692
|
|
|
|
|
|
|
%([%a-zA-Z]) # single character specifier like %d |
693
|
|
|
|
|
|
|
) |
694
|
|
|
|
|
|
|
/ |
695
|
|
|
|
|
|
|
( |
696
|
|
|
|
|
|
|
$1 |
697
|
|
|
|
|
|
|
? ( $self->can($1) ? $self->$1() : "\%{$1}" ) |
698
|
|
|
|
|
|
|
: $2 |
699
|
|
|
|
|
|
|
? ( $formats{$2} ? $formats{$2}->($self) : "\%$2" ) |
700
|
|
|
|
|
|
|
: $3 |
701
|
|
|
|
|
|
|
) |
702
|
|
|
|
|
|
|
/smgex; |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
if ( !wantarray ) { |
705
|
|
|
|
|
|
|
return $f; |
706
|
|
|
|
|
|
|
} |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
push @r, $f; |
709
|
|
|
|
|
|
|
} |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
return @r; |
712
|
|
|
|
|
|
|
} |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
=head3 utc_rd_values |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
Returns a three-element array containing the current UTC RD days, seconds, and |
717
|
|
|
|
|
|
|
nanoseconds. See L for more details. |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
=cut |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
sub utc_rd_values { |
722
|
|
|
|
|
|
|
my ($self) = @_; |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
return ( $self->{rd_days}, $self->{rd_secs}, $self->{rd_nanosecs} || 0 ); |
725
|
|
|
|
|
|
|
} |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
sub _era { |
728
|
|
|
|
|
|
|
my ($self) = @_; |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
return 0; |
731
|
|
|
|
|
|
|
} |
732
|
|
|
|
|
|
|
|
733
|
|
|
|
|
|
|
sub _masa_offset { |
734
|
|
|
|
|
|
|
my ($self) = @_; |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
return 1; |
737
|
|
|
|
|
|
|
} |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
sub _purnimanta { |
740
|
|
|
|
|
|
|
my ($self) = @_; |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
return 0; |
743
|
|
|
|
|
|
|
} |
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
=head2 UNITS OF TIME |
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
These methods return various parts of a chandramAna date. |
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
=head3 varsha |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
Returns the varSha. |
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
=cut |
754
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
sub varsha { |
756
|
|
|
|
|
|
|
my ($self) = @_; |
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
return $self->{varsha}; |
759
|
|
|
|
|
|
|
} |
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
=head3 adhikamasa |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
Returns 1 if this is an adhikamAsa or 0 if it is not. |
764
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
=cut |
766
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
sub adhikamasa { |
768
|
|
|
|
|
|
|
my ($self) = @_; |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
return $self->{adhikamasa}; |
771
|
|
|
|
|
|
|
} |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
=head3 adhikamasa_abbrev |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
Returns the abbreviated adhikamAsa name. (By default 'a '.) |
776
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
=cut |
778
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
sub adhikamasa_abbrev { |
780
|
|
|
|
|
|
|
my ($self) = @_; |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
return ( $self->{adhikamasa} ? $adhika_abbrev : undef ); |
783
|
|
|
|
|
|
|
} |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
=head3 adhikamasa_name |
786
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
Returns the full adhikamAsa name. (By default 'adhika '.) |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
=cut |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
sub adhikamasa_name { |
792
|
|
|
|
|
|
|
my ($self) = @_; |
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
return ( $self->{adhikamasa} ? $adhika_nama : undef ); |
795
|
|
|
|
|
|
|
} |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
=head3 masa |
798
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
Returns the mAsa as a number from 1 (chaitra) to 12 |
800
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
=cut |
802
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
sub masa { |
804
|
|
|
|
|
|
|
my ($self) = @_; |
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
return $self->{masa}; |
807
|
|
|
|
|
|
|
} |
808
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
=head3 masa_abbrev |
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
Returns the abbreviated mAsa name. |
812
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
=cut |
814
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
sub masa_abbrev { |
816
|
|
|
|
|
|
|
my ($self) = @_; |
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
return $masa_abbrev[ $self->{masa} - 1 ]; |
819
|
|
|
|
|
|
|
} |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
=head3 masa_name |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
Returns the full mAsa name. |
824
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
=cut |
826
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
sub masa_name { |
828
|
|
|
|
|
|
|
my ($self) = @_; |
829
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
return $masa_nama[ $self->{masa} - 1 ]; |
831
|
|
|
|
|
|
|
} |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
=head3 paksha |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
Returns 1 if this is the kR^iShNapakSha or 0 if it is the shuklapakSha. |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
=cut |
838
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
sub paksha { |
840
|
|
|
|
|
|
|
my ($self) = @_; |
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
return $self->{paksha}; |
843
|
|
|
|
|
|
|
} |
844
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
=head3 paksha_abbrev |
846
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
Returns the abbreviated pakSha name. By default either 'shu' for shukla or |
848
|
|
|
|
|
|
|
'kR^i' for kR^iShNa. |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
=cut |
851
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
sub paksha_abbrev { |
853
|
|
|
|
|
|
|
my ($self) = @_; |
854
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
return $paksha_abbrev[ $self->{paksha} ]; |
856
|
|
|
|
|
|
|
} |
857
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
=head3 paksha_name |
859
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
Returns the full paksha name. By default either shukla or kR^iShNa. |
861
|
|
|
|
|
|
|
|
862
|
|
|
|
|
|
|
=cut |
863
|
|
|
|
|
|
|
|
864
|
|
|
|
|
|
|
sub paksha_name { |
865
|
|
|
|
|
|
|
my ($self) = @_; |
866
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
return $paksha_nama[ $self->{paksha} ]; |
868
|
|
|
|
|
|
|
} |
869
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
=head3 adhikatithi |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
Returns 1 if this is an adhikatithi or 0 if it is not. |
873
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
=cut |
875
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
sub adhikatithi { |
877
|
|
|
|
|
|
|
my ($self) = @_; |
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
return $self->{adhikatithi}; |
880
|
|
|
|
|
|
|
} |
881
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
=head3 adhikatithi_abbrev |
883
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
Returns the abbreviated adhikatithi name. (By default 'a '.) |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
=cut |
887
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
sub adhikatithi_abbrev { |
889
|
|
|
|
|
|
|
my ($self) = @_; |
890
|
|
|
|
|
|
|
|
891
|
|
|
|
|
|
|
return ( $self->{adhikatithi} ? $adhika_abbrev : undef ); |
892
|
|
|
|
|
|
|
} |
893
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
=head3 adhikatithi_name |
895
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
Returns the full adhikatithi name. (By default 'adhika '.) |
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
=cut |
899
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
sub adhikatithi_name { |
901
|
|
|
|
|
|
|
my ($self) = @_; |
902
|
|
|
|
|
|
|
|
903
|
|
|
|
|
|
|
return ( $self->{adhikatithi} ? $adhika_nama : undef ); |
904
|
|
|
|
|
|
|
} |
905
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
=head3 tithi |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
Returns the tithi as a decimal number. |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
=cut |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
sub tithi { |
913
|
|
|
|
|
|
|
my ($self) = @_; |
914
|
|
|
|
|
|
|
|
915
|
|
|
|
|
|
|
return $self->{tithi}; |
916
|
|
|
|
|
|
|
} |
917
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
=head3 tithi_abbrev |
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
Returns the abbreviated tithi name. |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
=cut |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
sub tithi_abbrev { |
925
|
|
|
|
|
|
|
my ($self) = @_; |
926
|
|
|
|
|
|
|
|
927
|
|
|
|
|
|
|
if ( $self->{tithi} == 15 ) { |
928
|
|
|
|
|
|
|
return $purnima_abbrev; |
929
|
|
|
|
|
|
|
} |
930
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
if ( $self->{tithi} == 30 ) { |
932
|
|
|
|
|
|
|
return $amavasya_abbrev; |
933
|
|
|
|
|
|
|
} |
934
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
return $tithi_abbrev[ $self->{tithi} - 1 ]; |
936
|
|
|
|
|
|
|
} |
937
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
=head3 tithi_name |
939
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
Returns the full tithi name. |
941
|
|
|
|
|
|
|
|
942
|
|
|
|
|
|
|
=cut |
943
|
|
|
|
|
|
|
|
944
|
|
|
|
|
|
|
sub tithi_name { |
945
|
|
|
|
|
|
|
my ($self) = @_; |
946
|
|
|
|
|
|
|
|
947
|
|
|
|
|
|
|
if ( $self->{tithi} == 15 ) { |
948
|
|
|
|
|
|
|
return $purnima_nama; |
949
|
|
|
|
|
|
|
} |
950
|
|
|
|
|
|
|
|
951
|
|
|
|
|
|
|
if ( $self->{tithi} == 30 ) { |
952
|
|
|
|
|
|
|
return $amavasya_nama; |
953
|
|
|
|
|
|
|
} |
954
|
|
|
|
|
|
|
|
955
|
|
|
|
|
|
|
return $tithi_nama[ $self->{tithi} - 1 ]; |
956
|
|
|
|
|
|
|
} |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
=head3 vara |
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
Returns the vAra as a number from 1 (ravivAra) to 7. |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
=cut |
963
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
sub vara { |
965
|
|
|
|
|
|
|
my ($self) = @_; |
966
|
|
|
|
|
|
|
|
967
|
|
|
|
|
|
|
return $self->{vara}; |
968
|
|
|
|
|
|
|
} |
969
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
=head3 vara_abbrev |
971
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
Returns the abbreviated vAra name. |
973
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
=cut |
975
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
sub vara_abbrev { |
977
|
|
|
|
|
|
|
my ($self) = @_; |
978
|
|
|
|
|
|
|
|
979
|
|
|
|
|
|
|
return $vara_abbrev[ $self->{vara} - 1 ]; |
980
|
|
|
|
|
|
|
} |
981
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
=head3 vara_name |
983
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
Returns the full vAra name. |
985
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
=cut |
987
|
|
|
|
|
|
|
|
988
|
|
|
|
|
|
|
sub vara_name { |
989
|
|
|
|
|
|
|
my ($self) = @_; |
990
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
return $vara_nama[ $self->{vara} - 1 ]; |
992
|
|
|
|
|
|
|
} |
993
|
|
|
|
|
|
|
|
994
|
|
|
|
|
|
|
=head1 BUGS |
995
|
|
|
|
|
|
|
|
996
|
|
|
|
|
|
|
Please report any bugs or feature requests through the web interface at |
997
|
|
|
|
|
|
|
L. I |
998
|
|
|
|
|
|
|
will be notified, and then you’ll automatically be notified of progress |
999
|
|
|
|
|
|
|
on your bug as I make changes. B |
1000
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
=head1 SUPPORT |
1002
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
1004
|
|
|
|
|
|
|
|
1005
|
|
|
|
|
|
|
perldoc DateTime::Indic::Chandramana |
1006
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
Support requests for this module and questions about panchanga ganita should |
1008
|
|
|
|
|
|
|
be sent to the panchanga-devel@lists.braincells.com email list. See |
1009
|
|
|
|
|
|
|
L for more details. |
1010
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
Questions related to the DateTime API should be sent to the |
1012
|
|
|
|
|
|
|
datetime@perl.org email list. See L for more details. |
1013
|
|
|
|
|
|
|
|
1014
|
|
|
|
|
|
|
You can also look for information at: |
1015
|
|
|
|
|
|
|
|
1016
|
|
|
|
|
|
|
=over 4 |
1017
|
|
|
|
|
|
|
|
1018
|
|
|
|
|
|
|
=item * This projects git source code repository |
1019
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
L |
1021
|
|
|
|
|
|
|
|
1022
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
1023
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
L |
1025
|
|
|
|
|
|
|
|
1026
|
|
|
|
|
|
|
=item * CPAN Ratings |
1027
|
|
|
|
|
|
|
|
1028
|
|
|
|
|
|
|
L |
1029
|
|
|
|
|
|
|
|
1030
|
|
|
|
|
|
|
=item * Search CPAN |
1031
|
|
|
|
|
|
|
|
1032
|
|
|
|
|
|
|
L |
1033
|
|
|
|
|
|
|
|
1034
|
|
|
|
|
|
|
=back |
1035
|
|
|
|
|
|
|
|
1036
|
|
|
|
|
|
|
=head1 SEE ALSO |
1037
|
|
|
|
|
|
|
|
1038
|
|
|
|
|
|
|
L |
1039
|
|
|
|
|
|
|
|
1040
|
|
|
|
|
|
|
=head1 AUTHOR |
1041
|
|
|
|
|
|
|
|
1042
|
|
|
|
|
|
|
Jaldhar H. Vyas, C<< >> |
1043
|
|
|
|
|
|
|
|
1044
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
1045
|
|
|
|
|
|
|
|
1046
|
|
|
|
|
|
|
Copyright (C) 2009, Consolidated Braincells Inc. |
1047
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
1049
|
|
|
|
|
|
|
the terms of either: |
1050
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
=over 4 |
1052
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
=item * the GNU General Public License as published by the Free Software |
1054
|
|
|
|
|
|
|
Foundation; either version 2, or (at your option) any later version, or |
1055
|
|
|
|
|
|
|
|
1056
|
|
|
|
|
|
|
=item * the Artistic License version 2.0. |
1057
|
|
|
|
|
|
|
|
1058
|
|
|
|
|
|
|
=back |
1059
|
|
|
|
|
|
|
|
1060
|
|
|
|
|
|
|
The full text of the license can be found in the LICENSE file included |
1061
|
|
|
|
|
|
|
with this distribution. |
1062
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
=cut |
1064
|
|
|
|
|
|
|
|
1065
|
|
|
|
|
|
|
1; # End of DateTime::Indic::Chandramana |