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