line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package DateTime::Event::Zodiac; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
2
|
|
|
2
|
|
238100
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
87
|
|
5
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
68
|
|
6
|
2
|
|
|
2
|
|
1235
|
use utf8; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
15
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
64
|
use Exporter; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
106
|
|
9
|
2
|
|
|
2
|
|
12
|
use base qw(Exporter); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
202
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
2957
|
use DateTime; |
|
2
|
|
|
|
|
212264
|
|
|
2
|
|
|
|
|
118
|
|
12
|
2
|
|
|
2
|
|
2344
|
use DateTime::Astro qw(solar_longitude); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '1.03'; |
15
|
|
|
|
|
|
|
our @EXPORT = qw(); |
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw(zodiac_date_name zodiac_date_symbol zodiac_astro_name zodiac_astro_symbol zodiac_date zodiac_astro); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @ZODIAC = ( |
19
|
|
|
|
|
|
|
{ |
20
|
|
|
|
|
|
|
name => 'aries', |
21
|
|
|
|
|
|
|
symbol => "\x{2648}", |
22
|
|
|
|
|
|
|
start => '21.03', |
23
|
|
|
|
|
|
|
end => '20.04', |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
{ |
26
|
|
|
|
|
|
|
name => 'taurus', |
27
|
|
|
|
|
|
|
symbol => "\x{2649}", |
28
|
|
|
|
|
|
|
start => '21.04', |
29
|
|
|
|
|
|
|
end => '20.05', |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
name => 'gemini', |
33
|
|
|
|
|
|
|
symbol => "\x{264a}", |
34
|
|
|
|
|
|
|
start => '21.05', |
35
|
|
|
|
|
|
|
end => '21.06', |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
name => 'cancer', |
39
|
|
|
|
|
|
|
symbol => "\x{264b}", |
40
|
|
|
|
|
|
|
start => '22.06', |
41
|
|
|
|
|
|
|
end => '22.07', |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
{ |
44
|
|
|
|
|
|
|
name => 'leo', |
45
|
|
|
|
|
|
|
symbol => "\x{264c}", |
46
|
|
|
|
|
|
|
start => '23.07', |
47
|
|
|
|
|
|
|
end => '23.08', |
48
|
|
|
|
|
|
|
}, |
49
|
|
|
|
|
|
|
{ |
50
|
|
|
|
|
|
|
name => 'virgo', |
51
|
|
|
|
|
|
|
symbol => "\x{264d}", |
52
|
|
|
|
|
|
|
start => '24.08', |
53
|
|
|
|
|
|
|
end => '22.09', |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
{ |
56
|
|
|
|
|
|
|
name => 'libra', |
57
|
|
|
|
|
|
|
symbol => "\x{264e}", |
58
|
|
|
|
|
|
|
start => '23.09', |
59
|
|
|
|
|
|
|
end => '22.10', |
60
|
|
|
|
|
|
|
}, |
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
name => 'scorpius', |
63
|
|
|
|
|
|
|
symbol => "\x{264f}", |
64
|
|
|
|
|
|
|
start => '23.10', |
65
|
|
|
|
|
|
|
end => '21.11', |
66
|
|
|
|
|
|
|
}, |
67
|
|
|
|
|
|
|
{ |
68
|
|
|
|
|
|
|
name => 'sagittarius', |
69
|
|
|
|
|
|
|
symbol => "\x{2650}", |
70
|
|
|
|
|
|
|
start => '22.11', |
71
|
|
|
|
|
|
|
end => '21.12', |
72
|
|
|
|
|
|
|
}, |
73
|
|
|
|
|
|
|
{ |
74
|
|
|
|
|
|
|
name => 'capricornus', |
75
|
|
|
|
|
|
|
symbol => "\x{2651}", |
76
|
|
|
|
|
|
|
start => '22.12', |
77
|
|
|
|
|
|
|
end => '19.01', |
78
|
|
|
|
|
|
|
}, |
79
|
|
|
|
|
|
|
{ |
80
|
|
|
|
|
|
|
name => 'aquarius', |
81
|
|
|
|
|
|
|
symbol => "\x{2652}", |
82
|
|
|
|
|
|
|
start => '20.01', |
83
|
|
|
|
|
|
|
end => '18.02', |
84
|
|
|
|
|
|
|
}, |
85
|
|
|
|
|
|
|
{ |
86
|
|
|
|
|
|
|
name => 'pisces', |
87
|
|
|
|
|
|
|
symbol => "\x{2653}", |
88
|
|
|
|
|
|
|
start => '19.02', |
89
|
|
|
|
|
|
|
end => '20.03', |
90
|
|
|
|
|
|
|
}, |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=encoding utf8 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=pod |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 NAME |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
DateTime::Event::Zodiac - Return zodiac for a given date |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SYNOPSIS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
use DateTime::Event::Zodiac qw(zodiac_date_name zodiac_date_symbol zodiac_astro_name zodiac_astro_symbol); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $dt = DateTime->new( |
106
|
|
|
|
|
|
|
year => 1979, |
107
|
|
|
|
|
|
|
month => 3, |
108
|
|
|
|
|
|
|
day => 27, |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
print zodiac_date_name($dt); |
112
|
|
|
|
|
|
|
print zodiac_astro_symbol($dt); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Returns the latin zodiac name or alternatively the unicode zodiac symbol |
115
|
|
|
|
|
|
|
for the given date. The zodiac may be calculated using either fixed dates or |
116
|
|
|
|
|
|
|
using the exact longitude of the sun. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
The module exports no symbols by default. All used functions must be requested |
119
|
|
|
|
|
|
|
in the use statement. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
All methods return undef on failure. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 DESCRIPTION |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 zodiac_date_name |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$name = zodiac_date_name($dt); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Latin zodiac name: aries, taurus, gemini, cancer, leo, virgo, libra, scorpius, |
130
|
|
|
|
|
|
|
sagittarius, capricornus, aquarius and pisces. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Fixed dates. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 zodiac_date_symbol |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
$symbol = zodiac_date_symbol($dt); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Unicode zodiac symbol positions U+2648 to U+2653. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Fixed dates. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 zodiac_astro_name |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
$name = zodiac_astro_name($dt); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Latin zodiac name: aries, taurus, gemini, ... |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Calculated from the longitude of the sun. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 zodiac_astro_symbol |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
$symbol = zodiac_astro_symbol($dt); |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Unicode zodiac symbol positions U+2648 to U+2653. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Calculated from the longitude of the sun. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 zodiac_date |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Simply computes the zodiac from the fixed date and returns a hash with the keys |
161
|
|
|
|
|
|
|
name, symbol, start and end. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Used internally by C and C |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 zodiac_astro |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Computes the zodiac from the position of the sun and returns a hash with the |
168
|
|
|
|
|
|
|
keys name, symbol, start and end. The keys start and end should be ignored |
169
|
|
|
|
|
|
|
since they are only used for the C function. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
May differ from the results of C depending on the solar year |
172
|
|
|
|
|
|
|
(leap year ect). |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
See L for notes on accuracy. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Used internally by C and C |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
181
|
|
|
|
|
|
|
sub zodiac_date_name |
182
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
183
|
|
|
|
|
|
|
{ |
184
|
|
|
|
|
|
|
my ($datetime) = @_; |
185
|
|
|
|
|
|
|
my $zodiac = zodiac_date($datetime); |
186
|
|
|
|
|
|
|
return defined $zodiac ? $zodiac->{name}:undef; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
190
|
|
|
|
|
|
|
sub zodiac_date_symbol |
191
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
192
|
|
|
|
|
|
|
{ |
193
|
|
|
|
|
|
|
my ($datetime) = @_; |
194
|
|
|
|
|
|
|
my $zodiac = zodiac_date($datetime); |
195
|
|
|
|
|
|
|
return defined $zodiac ? $zodiac->{symbol}:undef; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
199
|
|
|
|
|
|
|
sub zodiac_astro_name |
200
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
201
|
|
|
|
|
|
|
{ |
202
|
|
|
|
|
|
|
my ($datetime) = @_; |
203
|
|
|
|
|
|
|
my $zodiac = zodiac_astro($datetime); |
204
|
|
|
|
|
|
|
return defined $zodiac ? $zodiac->{name}:undef; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
208
|
|
|
|
|
|
|
sub zodiac_astro_symbol |
209
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
210
|
|
|
|
|
|
|
{ |
211
|
|
|
|
|
|
|
my ($datetime) = @_; |
212
|
|
|
|
|
|
|
my $zodiac = zodiac_astro($datetime); |
213
|
|
|
|
|
|
|
return defined $zodiac ? $zodiac->{symbol}:undef; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
217
|
|
|
|
|
|
|
sub zodiac_date |
218
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
219
|
|
|
|
|
|
|
{ |
220
|
|
|
|
|
|
|
my ($date) = @_; |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
die('Must specify a DateTime object') unless (defined $date |
223
|
|
|
|
|
|
|
&& ref($date) |
224
|
|
|
|
|
|
|
&& $date->isa('DateTime')); |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
# Loop all zodiacs |
227
|
|
|
|
|
|
|
foreach my $zodiac (@ZODIAC) { |
228
|
|
|
|
|
|
|
my $start = _convertdate($zodiac->{start},$date->year,0,0); |
229
|
|
|
|
|
|
|
my $end = _convertdate($zodiac->{end},$date->year,23,59); |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
next unless defined $start && defined $end; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# Special case: Zodiac spans new year |
234
|
|
|
|
|
|
|
if ($start->month > $end->month) { |
235
|
|
|
|
|
|
|
# Check zodiac for past year |
236
|
|
|
|
|
|
|
$start->set(year => $start->year -1); |
237
|
|
|
|
|
|
|
return $zodiac if ($date >= $start && $date <= $end); |
238
|
|
|
|
|
|
|
# Reset and search current year too |
239
|
|
|
|
|
|
|
$start->set(year => $start->year +1); |
240
|
|
|
|
|
|
|
$end->set(year => $end->year + 1); |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
# Check zodiac |
244
|
|
|
|
|
|
|
return $zodiac if ($date >= $start && $date <= $end); |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
return undef; |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
251
|
|
|
|
|
|
|
sub zodiac_astro |
252
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
253
|
|
|
|
|
|
|
{ |
254
|
|
|
|
|
|
|
my ($date) = @_; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
die('Must specify a DateTime object') unless (defined $date |
257
|
|
|
|
|
|
|
&& ref($date) |
258
|
|
|
|
|
|
|
&& $date->isa('DateTime')); |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
# Get longitude (0-360) for given DateTime object |
261
|
|
|
|
|
|
|
my $longitude = solar_longitude($date); |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
return undef unless defined $longitude; |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
# Return the zodiac |
266
|
|
|
|
|
|
|
return $ZODIAC[int($longitude / 30)]; |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
270
|
|
|
|
|
|
|
sub _convertdate |
271
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
272
|
|
|
|
|
|
|
{ |
273
|
|
|
|
|
|
|
my ($date,$year,$hour,$minute) = @_; |
274
|
|
|
|
|
|
|
if ($date =~ m/^(\d\d)\.(\d\d)$/) { |
275
|
|
|
|
|
|
|
my $dt = DateTime->new( |
276
|
|
|
|
|
|
|
month => $2, |
277
|
|
|
|
|
|
|
day => $1, |
278
|
|
|
|
|
|
|
year => $year, |
279
|
|
|
|
|
|
|
hour => $hour, |
280
|
|
|
|
|
|
|
minute => $minute, |
281
|
|
|
|
|
|
|
); |
282
|
|
|
|
|
|
|
return $dt; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
return undef; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=head1 DISCLAIMER |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
The author of this module regads astrology as being a pseudoscience and |
290
|
|
|
|
|
|
|
superstition. I wrote this module for my job. I was young, foolish and |
291
|
|
|
|
|
|
|
I needed the money. |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=head1 TODO |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
The C and C functions have not |
296
|
|
|
|
|
|
|
yet been implemented and probably never will be ;-) |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=head1 SUPPORT |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
301
|
|
|
|
|
|
|
C, or through the web interface at |
302
|
|
|
|
|
|
|
L. |
303
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
304
|
|
|
|
|
|
|
your report as I make changes. |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=head1 AUTHOR |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
Maroš Kollár |
309
|
|
|
|
|
|
|
CPAN ID: MAROS |
310
|
|
|
|
|
|
|
maros [at] k-1.com |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
L |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=head1 COPYRIGHT |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
DateTime::Event::Zodiac is Copyright (c) 2008-13 Maroš Kollár |
317
|
|
|
|
|
|
|
- L |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
This program is free software; you can redistribute |
320
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
The full text of the license can be found in the |
323
|
|
|
|
|
|
|
LICENSE file included with this module. |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=cut |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
q[I do not believe in this rubbish |
328
|
|
|
|
|
|
|
I do not believe in this rubbish |
329
|
|
|
|
|
|
|
I do not believe in this rubbish |
330
|
|
|
|
|
|
|
I do not believe in this rubbish |
331
|
|
|
|
|
|
|
I do not bel....]; |