Jewish/Eqt.pm

filter: Statementstmt 55.8% 24 / 43 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 52.5% 31 / 59 CC 5 SCAR 26.5
CC
5
Cov
47%
eqt
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 14.2
« Jewish/Sunrise.pm ↑ Summary Jewish.pm »
1 package DateTime::Event::Jewish::Eqt;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use DateTime::Duration;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use vars qw(@EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 our $VERSION = '0.01';
9 3 @EXPORT_OK = qw(eqt %eqt);
10  
11 =head1 NAME
12  
13 Eqt - Equation of time
14  
15 =head1 Synopsis
16  
17 Returns the Equation of Time (the variation of solar time from
18 clock time) for a given day in the year.
19  
20 -ve times are sundial slow of clock.
21  
22  
23 =cut
24  
25 3 our %eqt=(
26 "Jan"=>[
27 "-3:12",
28 "-3:40",
29 "-4:08",
30 "-4:36",
31 "-5:03",
32  
33 "-5:30",
34 "-5:57",
35 "-6:23",
36 "-6:49",
37 "-7:14",
38  
39 "-7:38",
40 "-8:02",
41 "-8:25",
42 "-8:48",
43 "-9:10",
44  
45 "-9:32",
46 "-9:52",
47 "-10:12",
48 "-12:32",
49 "-10:50",
50  
51 "-11:08",
52 "-11:25",
53 "-11:41",
54 "-11:57",
55 "-12:12",
56  
57 "-12:26",
58 "-12:39",
59 "-12:51",
60 "-13:03",
61 "-13:14",
62 "-13:24",
63 ],
64 "Feb"=>[
65 "-13:33",
66 "-13:41",
67 "-13:48",
68 "-13:55",
69 "-14:01",
70  
71 "-14:06",
72 "-14:10",
73 "-14:14",
74 "-14:16",
75 "-14:18",
76  
77 "-14:19",
78 "-14:20",
79 "-14:19",
80 "-14:18",
81 "-14:16",
82  
83 "-14:13",
84 "-14:10",
85 "-14:06",
86 "-14:01",
87 "-13:55",
88  
89 "-13:49",
90 "-13:42",
91 "-13:35",
92 "-13:27",
93 "-13:18",
94  
95 "-13:09",
96 "-12:59",
97 "-12:48",
98 "-12:42",
99 ],
100 "Mar"=>[
101 "-12:34",
102 "-12:23",
103 "-12:11",
104 "-11:58",
105 "-11:45",
106  
107 "-11:31",
108 "-11:17",
109 "-11:03",
110 "-10:48",
111 "-10:33",
112  
113 "-10:18",
114 "-10:02",
115 "-9:46",
116 "-9:30",
117 "-9:13",
118  
119 "-8:56",
120 "-8:39",
121 "-8:22",
122 "-8:04",
123 "-7:46",
124  
125 "-7:28",
126 "-7:10",
127 "-6:52",
128 "-6:34",
129 "-6:16",
130  
131 "-5:58",
132 "-5:40",
133 "-5:21",
134 "-5:02",
135 "-4:44",
136 "-4:26",
137 ],
138 "Apr"=>[
139 "-4:08",
140 "-3:50",
141 "-3:32",
142 "-3:14",
143 "-2:57",
144  
145 "-2:40",
146 "-2:23",
147 "-2:06",
148 "-1:49",
149 "-1:32",
150  
151 "-1:16",
152 "-1:00",
153 "-0:44",
154 "-0:29",
155 "-0:14",
156  
157 "0:01",
158 "0:15",
159 "0:29",
160 "0:43",
161 "0:56",
162  
163 "1:00",
164 "1:21",
165 "1:33",
166 "1:45",
167 "1:56",
168  
169 "2:06",
170 "2:16",
171 "2:26",
172 "2:35",
173 "2:43",
174 ],
175 "May"=>[
176 "2:51",
177 "2:59",
178 "3:06",
179 "3:12",
180 "3:18",
181  
182 "3:23",
183 "3:27",
184 "3:31",
185 "3:35",
186 "3:38",
187  
188 "3:40",
189 "3:42",
190 "3:44",
191 "3:44",
192 "3:44",
193  
194 "3:44",
195 "3:43",
196 "3:41",
197 "3:39",
198 "3:37",
199  
200 "3:34",
201 "3:30",
202 "3:24",
203 "3:21",
204 "3:16",
205  
206 "3:10",
207 "3:03",
208 "2:56",
209 "2:49",
210 "2:41",
211 "2:33",
212 ],
213 "Jun"=>[
214 "2:25",
215 "2:16",
216 "2:06",
217 "1:56",
218 "1:46",
219  
220 "1:36",
221 "1:25",
222 "1:14",
223 "1:03",
224 "0:51",
225  
226 "0:39",
227 "0:27",
228 "0:15",
229 "0:03",
230 "-0:10",
231  
232 "-0:23",
233 "-0:36",
234 "-0:49",
235 "-1:02",
236 "-1:15",
237  
238 "-1:28",
239 "-1:41",
240 "-1:54",
241 "-2:07",
242 "-2:20",
243  
244 "-2:33",
245 "-2:45",
246 "-2:57",
247 "-3:09",
248 "-3:21",
249 ],
250 "Jul"=>[
251 "-3:33",
252 "-3:45",
253 "-3:57",
254 "-4:08",
255 "-4:19",
256  
257 "-4:29",
258 "-4:39",
259 "-4:49",
260 "-4:58",
261 "-5:07",
262  
263 "-5:16",
264 "-5:24",
265 "-5:32",
266 "-5:39",
267 "-5:46",
268  
269 "-5:52",
270 "-5:58",
271 "-6:03",
272 "-6:08",
273 "-6:12",
274  
275 "-6:15",
276 "-6:18",
277 "-6:20",
278 "-6:22",
279 "-6:24",
280  
281 "-6:25",
282 "-6:25",
283 "-6:24",
284 "-6:23",
285 "-6:21",
286 "-6:19",
287 ],
288 "Aug"=>[
289 "-6:16",
290 "-6:13",
291 "-6:09",
292 "-6:04",
293 "-5:59",
294  
295 "-5:53",
296 "-5:46",
297 "-5:39",
298 "-5:31",
299 "-5:23",
300  
301 "-5:14",
302 "-5:05",
303 "-4:55",
304 "-4:44",
305 "-4:33",
306  
307 "-4:21",
308 "-4:09",
309 "-3:57",
310 "-3:44",
311 "-3:30",
312  
313 "-3:16",
314 "-3:01",
315 "-2:46",
316 "-2:30",
317 "-2:14",
318  
319 "-1:58",
320 "-1:41",
321 "-1:24",
322 "-1:07",
323 "-0:49",
324 "-0:31",
325 ],
326 "Sep"=>[
327 "-0:12",
328 "0:07",
329 "0:26",
330 "0:45",
331 "1:05",
332  
333 "1:25",
334 "1:45",
335 "2:05",
336 "2:26",
337 "2:47",
338  
339 "3:08",
340 "3:29",
341 "3:50",
342 "4:11",
343 "4:32",
344  
345 "4:53",
346 "5:14",
347 "5:35",
348 "5:56",
349 "6:18",
350  
351 "6:40",
352 "7:01",
353 "7:22",
354 "7:43",
355 "8:04",
356  
357 "8:25",
358 "8:46",
359 "9:06",
360 "9:26",
361 "9:46",
362 ],
363 "Oct"=>[
364 "10:05",
365 "10:24",
366 "10:43",
367 "11:02",
368 "11:20",
369  
370 "11:38",
371 "11:56",
372 "12:13",
373 "12:30",
374 "12:46",
375  
376 "13:02",
377 "13:18",
378 "13:33",
379 "13:47",
380 "14:01",
381  
382 "14:14",
383 "14:27",
384 "14:39",
385 "14:51",
386 "15:01",
387  
388 "15:12",
389 "15:22",
390 "15:31",
391 "15:40",
392 "15:47",
393  
394 "15:54",
395 "16:01",
396 "16:06",
397 "16:11",
398 "16:15",
399 "16:18",
400 ],
401 "Nov"=>[
402 "16:20",
403 "16:22",
404 "16:23",
405 "16:23",
406 "16:22",
407  
408 "16:20",
409 "16:18",
410 "16:15",
411 "16:11",
412 "16:06",
413  
414 "16:00",
415 "15:53",
416 "15:46",
417 "15:37",
418 "15:28",
419  
420 "15:18",
421 "15:07",
422 "14:56",
423 "14:43",
424 "14:30",
425  
426 "14:16",
427 "14:01",
428 "13:45",
429 "13:28",
430 "13:11",
431  
432 "12:53",
433 "12:34",
434 "12:14",
435 "11:54",
436 "11:33",
437 ],
438 "Dec"=>[
439 "11:11",
440 "10:49",
441 "10:26",
442 "10:02",
443 "9:38",
444  
445 "9:13",
446 "8:48",
447 "8:22",
448 "7:56",
449 "7:29",
450  
451 "7:02",
452 "6:34",
453 "6:06",
454 "5:38",
455 "5:09",
456  
457 "4:40",
458 "4:11",
459 "3:42",
460 "3:13",
461 "2:43",
462  
463 "2:13",
464 "1:43",
465 "1:13",
466 "0:43",
467 "0:13",
468  
469 "-0:17",
470 "-0:47",
471 "-1:16",
472 "-1:45",
473 "-2:14",
474 "-2:43",
475 ],
476 );
477 3 our @months=("Jan", "Feb", "Mar", "Apr", "May", "Jun",
478 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
479  
480  
481 =head3 eqt($date)
482  
483 Returns the deviation of solar time from clock time in minutes.
484  
485 Add to clock time to get sundial time;
486 subtract from sundial time to get clock time.
487  
488 =over
489  
490 =item $date
491  
492 A DateTime object. Only the day and month are relevant.
493  
494 =back
495  
496 =cut
497  
498 0 ▶sub eqt {
Subroutine eqt: not called CC=5 SCAR=34.0
Pod documented
499 0 my $date= shift;
500 # Do some basic validation
501 0 my ($day, $month) = ($date->day, $date->month);
502 0 ▶ if ($month !~ /^\w+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($month =~ /^\w+$/) 0 0 0
503 0 print "Bad month: not alphanumeric $month\n";
504 0 return undef;
505 }
506 0 ▶ if ($day !~ /^[0-9]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($day =~ /^[0-9]+$/) 0 0 0
507 0 print "(eqt) Bad day: not numeric $day\n";
508 0 return undef;
509 }
510 0 ▶ if ($month =~ /^[0-9]+$/) { $month = $months[$month-1];}
Branch: 1 branch
BranchTrueFalseTotal
if ($month =~ /^[0-9]+$/) 0 0 0
511 0 $month = ucfirst($month); # Get the case right
512  
513 # Get the offset for this date.
514 0 my $decl = $eqt{$month}[$day-1];
515 0 my ($min, $sec) = ($decl =~ /([^:]+):([^:]+)/);
516 0 $min = int($min);
517 0 $sec = int($sec);
518 0 ▶ if ($min < 0){ $sec = -$sec;}
Branch: 1 branch
BranchTrueFalseTotal
if ($min < 0) 0 0 0
519 0 $min += $sec/60.0;
520 0 return $min;
521 }
522  
523  
524 3 1;
525  
526 =head1 AUTHOR
527  
528 Raphael Mankin, C<< <rapmankin at cpan.org> >>
529  
530 =head1 BUGS
531  
532 Please report any bugs or feature requests to C<bug-datetime-event-jewish at rt.cpan.org>, or through
533 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DateTime-Event-Jewish>. I will be notified, and then you'll
534 automatically be notified of progress on your bug as I make changes.
535  
536  
537  
538  
539 =head1 SUPPORT
540  
541 You can find documentation for this module with the perldoc command.
542  
543 perldoc DateTime::Event::Jewish
544  
545  
546 You can also look for information at:
547  
548 =over 4
549  
550 =item * RT: CPAN's request tracker
551  
552 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime-Event-Jewish>
553  
554 =item * AnnoCPAN: Annotated CPAN documentation
555  
556 L<http://annocpan.org/dist/DateTime-Event-Jewish>
557  
558 =item * CPAN Ratings
559  
560 L<http://cpanratings.perl.org/d/DateTime-Event-Jewish>
561  
562 =item * Search CPAN
563  
564 L<http://search.cpan.org/dist/DateTime-Event-Jewish/>
565  
566 =back
567  
568  
569 =head1 ACKNOWLEDGEMENTS
570  
571  
572 =head1 LICENSE AND COPYRIGHT
573  
574 Copyright 2010 Raphael Mankin.
575  
576 This program is free software; you can redistribute it and/or modify it
577 under the terms of either: the GNU General Public License as published
578 by the Free Software Foundation; or the Artistic License.
579  
580 See http://dev.perl.org/licenses/ for more information.
581  
582  
583 =cut
584  
585 3 1; # End of DateTime::Event::Eqt
« Jewish/Sunrise.pm ↑ Summary Jewish.pm »