DateTime-Event-Sunrise-0.0505/0000755000175000017500000000000012631373464013575 5ustar jfjfDateTime-Event-Sunrise-0.0505/Makefile.PL0000644000175000017500000000767512631373340015557 0ustar jfjf# # Configuration script for DateTime::Event::Sunrise # Copyright (C) 2003, 2004, 2013, 2015 Ron Hill and Jean Forget # # This program is distributed under the same terms as Perl 5.16.3: # GNU Public License version 1 or later and Perl Artistic License # # You can find the text of the licenses in the F file or at # L # and L. # # Here is the summary of GPL: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., . # use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'DateTime::Event::Sunrise', 'VERSION_FROM' => 'lib/DateTime/Event/Sunrise.pm', # finds $VERSION 'ABSTRACT' => 'Perl DateTime extension for computing the sunrise/sunset on a given day', 'PREREQ_PM' => { 'DateTime::Set' => '0.16', 'DateTime' => '0.21', 'POSIX' => '0', # how can I find the minimum version without trying all of them? At least mention the dependency. 'Math::Trig' => '0', 'Carp' => '0', 'Params::Validate' => '0', 'Set::Infinite' => '0', }, 'AUTHOR' => [ 'Ron Hill ', 'Jean Forget ' ], 'LICENSE' => 'perl', # The oldest Perl to check DT::E::Sunrise 0.0504 is 5.8.5. Therefore, I guess DT::E::Sunrise 0.0505 and next will work in 5.8.5 too. MIN_PERL_VERSION => '5.8.5', 'BUILD_REQUIRES' => { 'Test::More' => '0', # should be 'TEST_REQUIRES', except that ExtUtils::MakeMaker 6.5705 does not accept it 'DateTime::Duration' => '0', 'DateTime::Span' => '0', 'DateTime::SpanSet' => '0', 'Test::Exception' => '0', 'ExtUtils::MakeMaker' => '6.57_02', # the first version to accept several authors in an arrayref }, META_MERGE => { prereqs => { runtime => { requires => { 'DateTime' => '0.16', 'DateTime::Duration' => '0', 'DateTime::Span' => '0', 'DateTime::SpanSet' => '0', 'perl' => '5.8.5', }, }, build => { requires => { 'Test::More' => '0', 'ExtUtils::MakeMaker' => '6.57_02', # the first version to accept several authors in an arrayref }, }, }, provides => { 'DateTime::Event::Sunrise' => { file => 'lib/DateTime/Event/Sunrise.pm', version => '0.0505', }, }, 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => 'https://github.com/jforget/DateTime-Event-Sunrise.git', web => 'https://github.com/jforget/DateTime-Event-Sunrise', }, }, }, ); DateTime-Event-Sunrise-0.0505/TODO0000644000175000017500000000352012364263171014261 0ustar jfjf-*- encoding: utf-8; indent-tabs-mode: nil -*- TO DO ===== Play the CPANTS game -------------------- But remember that this is not an end in itself. It is just a mean (kwalitee checking) towards an end (quality). For example, the module did not get the points for the LICENSE POD paragraph. Yet, there is a LICENSE POD paragraph. Just the automated CPANTS check did not recognize its contents. But any human reader will admit the paragraph is correct. So this is a kwalitee issue I will not fix. And I will not complain to the authors of the programs that power the CPANTS site. I have better things to do and they have better things to do. But there are other issues that need to be fixed. I will fix them (when the CPANTS website is up; at the moment it is down). Play the Devel::Cover game -------------------------- I know that you can have 100% code coverage and still have bugs in your module. Yet, having a poor coverage is a sure recipe to have lurking bugs in your code. So I will strive to have a better code coverage, while not forgetting to expand the data coverage. Yet, the original author has provided six trigonometrical function using degrees: sin, cos, tan, asin, acos, atan. But only three of them are used in the module. So the other three are not covered by the tests. I will leave them just like that, I will neither delete them, nor create a bogus test file just to ensure there are green-colored in the Devel::Cover reports. Other topics ------------ I have mentionned data coverage. In fact, the "precise" algorithm is not truly checked. It is colored in green with Devel::Cover, but I have not compared its output with another source. Since this module is OO, there could be convenience accessors, retrieving the longitude and the latitude of a given DT::E::Sunrise object. There is always room for improvement in the documentation. DateTime-Event-Sunrise-0.0505/t/0000755000175000017500000000000012631373464014040 5ustar jfjfDateTime-Event-Sunrise-0.0505/t/07loop.t0000644000175000017500000000460012631367401015337 0ustar jfjf# -*- encoding: utf-8; indent-tabs-mode: nil -*- # # Test script for DateTime::Event::Sunrise # Copyright (C) 2003, 2004, 2013 Ron Hill and Jean Forget # # This program is distributed under the same terms as Perl 5.16.3: # GNU Public License version 1 or later and Perl Artistic License # # You can find the text of the licenses in the F file or at # L # and L. # # Here is the summary of GPL: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # use strict; use POSIX qw(floor ceil); use Test::More; use DateTime; use DateTime::Duration; use DateTime::Span; use DateTime::SpanSet; use DateTime::Event::Sunrise; my $fudge = 2; plan tests => 2; my $dt = DateTime->new( year => 2015, month => 11, day => 27, ); my $dt2 = DateTime->new( year => 2015, month => 11, day => 27, ); my $sunrise = DateTime::Event::Sunrise ->sunrise( longitude =>'177', latitude => '-37.66667', altitude => 6, precise => 1, ); my $sunset = DateTime::Event::Sunrise ->sunset( longitude =>'177', latitude => '-37.66667', altitude => 6, precise => 1, ); my $tmp_rise = $sunrise->current($dt2); my $tmp_set = $sunset->current($dt); is ($tmp_rise->datetime, '2015-11-26T17:21:45', 'current sunrise'); is ($tmp_set->datetime, '2015-11-27T06:33:22', 'current sunset'); DateTime-Event-Sunrise-0.0505/t/00load.t0000644000175000017500000000254312200352523015271 0ustar jfjf# # Test script for DateTime::Event::Sunrise # Copyright (C) 2003, 2004, 2013 Ron Hill and Jean Forget # # This program is distributed under the same terms as Perl 5.16.3: # GNU Public License version 1 or later and Perl Artistic License # # You can find the text of the licenses in the F file or at # L # and L. # # Here is the summary of GPL: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # use strict; use Test; BEGIN {$| = 1; plan tests => 1 } use DateTime; use DateTime::Event::Sunrise; my $loaded = 1; ok($loaded); DateTime-Event-Sunrise-0.0505/t/02March21.t0000644000175000017500000000412712225607071015561 0ustar jfjf# # Test script for DateTime::Event::Sunrise # Copyright (C) 2013 Ron Hill and Jean Forget # # This program is distributed under the same terms as Perl 5.16.3: # GNU Public License version 1 or later and Perl Artistic License # # You can find the text of the licenses in the F file or at # L # and L. # # Here is the summary of GPL: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # use strict; use POSIX qw(floor ceil); use Test::More; use DateTime; use DateTime::Event::Sunrise; my @tests = split "\n", <<'TEST'; 2.33 48.83 1 20 18:04:42 2.33 48.83 1 21 18:06:12 2.33 48.83 1 22 18:07:43 92.33 48.83 0 20 12:03:10 92.33 48.83 0 21 12:04:41 92.33 48.83 0 22 12:06:11 TEST plan (tests => scalar @tests); foreach (@tests) { my ($lon, $lat, $precise, $dd, $res) = split ' ', $_; my $sunset = DateTime::Event::Sunrise->sunset(longitude => $lon, latitude => $lat, precise => $precise, upper_limb => 0, ); my $day = DateTime->new(year => 2008, month => 3, day => $dd, time_zone => 'UTC'); is ($sunset->next($day)->strftime("%H:%M:%S"), $res); } DateTime-Event-Sunrise-0.0505/t/03nextprev.t0000644000175000017500000000523212225573736016250 0ustar jfjf# # Test script for DateTime::Event::Sunrise (see RT ticket 36532) # Copyright (C) 2013 Ron Hill and Jean Forget # # This program is distributed under the same terms as Perl 5.16.3: # GNU Public License version 1 or later and Perl Artistic License # # You can find the text of the licenses in the F file or at # L # and L. # # Here is the summary of GPL: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # use strict; use POSIX qw(floor ceil); use Test::More; use DateTime; use DateTime::Event::Sunrise; my @tests = split "\n", <<'TEST'; 1212537601 46.74575 -65.2488 1212536601 64.74575 -220.2488 TEST plan (tests => 4 * scalar @tests); foreach (@tests) { my ($epoch, $lat, $lon) = split ' ', $_; my $sunrise = DateTime::Event::Sunrise->sunrise(longitude => $lon, latitude => $lat, precise => 1, ); my $sunset = DateTime::Event::Sunrise->sunset (longitude => $lon, latitude => $lat, precise => 1, ); my $dt = DateTime->from_epoch(epoch => $epoch); my $next_sunrise = $sunrise->next($dt); my $next_sunset = $sunset ->next($dt); my $prev_sunrise = $sunrise->previous($dt); my $prev_sunset = $sunset ->previous($dt); ok($next_sunrise->epoch() > $epoch, "Next sunrise ($next_sunrise) should be after dt ($dt)"); ok($next_sunset ->epoch() > $epoch, "Next sunset ($next_sunset) should be after dt ($dt)"); ok($prev_sunrise->epoch() < $epoch, "Prev sunrise ($prev_sunrise) should be before dt ($dt)"); ok($prev_sunset ->epoch() < $epoch, "Prev sunset ($prev_sunset) should be before dt ($dt)"); } DateTime-Event-Sunrise-0.0505/t/01basic.t0000644000175000017500000004177312230021040015432 0ustar jfjf# -*- encoding: utf-8; indent-tabs-mode: nil -*- # # Test script for DateTime::Event::Sunrise # Copyright (C) 2003, 2004, 2013 Ron Hill and Jean Forget # # This program is distributed under the same terms as Perl 5.16.3: # GNU Public License version 1 or later and Perl Artistic License # # You can find the text of the licenses in the F file or at # L # and L. # # Here is the summary of GPL: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # use strict; use POSIX qw(floor ceil); use Test::More; use DateTime; use DateTime::Duration; use DateTime::Span; use DateTime::SpanSet; use DateTime::Event::Sunrise; my $fudge = 2; my @data = data(); plan tests => 14 + 2 * @data; my $dt = DateTime->new( year => 2000, month => 6, day => 20, time_zone => 'America/Los_Angeles', ); my $dt2 = DateTime->new( year => 2000, month => 6, day => 22, time_zone => 'America/Los_Angeles', ); my $sunrise = DateTime::Event::Sunrise ->sunrise( longitude =>'-118', latitude => '33', upper_limb => 1, ); my $sunset = DateTime::Event::Sunrise ->sunset( longitude =>'-118', latitude => '33', upper_limb => 1, ); my $tmp_rise = $sunrise->current($dt); my $tmp_set = $sunset->current($dt); is ($tmp_rise->datetime, '2000-06-19T05:42:07', 'current sunrise'); is ($tmp_set->datetime, '2000-06-19T20:04:49', 'current sunset'); is ( $sunrise->current( $tmp_rise )->set_time_zone( 'America/Los_Angeles' )->datetime, '2000-06-19T05:42:07', 'current sunrise unchanged'); is ( $sunset->current( $tmp_set )->set_time_zone( 'America/Los_Angeles' )->datetime, '2000-06-19T20:04:49', 'current sunset unchanged'); is ( $sunrise->next( $tmp_rise )->set_time_zone( 'America/Los_Angeles' )->datetime, '2000-06-20T05:42:19', 'next sunrise'); is ( $sunset->next( $tmp_set )->set_time_zone( 'America/Los_Angeles' )->datetime, '2000-06-20T20:05:03', 'next sunset'); is ( $sunrise->previous( $tmp_rise )->set_time_zone( 'America/Los_Angeles' )->datetime, '2000-06-18T05:41:56', 'previous sunrise'); is ( $sunset->previous( $tmp_set )->set_time_zone( 'America/Los_Angeles' )->datetime, '2000-06-18T20:04:33', 'previous sunset'); is ( $sunrise->contains( $tmp_rise ), 1, 'is sunrise'); is ( $sunset->contains( $tmp_set ), 1, 'is sunset'); is ( $sunrise->contains( $dt ), 0, 'is not sunrise'); is ( $sunset->contains( $dt ), 0, 'is not sunset'); # I need to check this test, Flavio has changed this as of ver 0.14 od spanset #my $dt_span = DateTime::Span->new( start =>$dt, end=>$dt2 ); #my $set = $sunrise->intersection($dt_span); #my $iter = $set->iterator; #my @res; #for (0..1) { # my $tmp = $iter->next; # push @res, $tmp->datetime if defined $tmp; #} #my $res = join( ' ', @res ); #ok( $res eq '2000-06-19T05:43:43 2000-06-20T05:43:43'); my $sun = DateTime::Event::Sunrise ->new( longitude =>'-118', latitude => '33', upper_limb => 1, ); my $tmp_set1 = $sun->sunrise_sunset_span($dt); $tmp_set->set_time_zone('America/Los_Angeles'); ok( $tmp_set1->start->datetime eq '2000-06-20T05:42:19'); ok( $tmp_set1->end->datetime eq '2000-06-20T20:05:03'); use vars qw($long $lat $offset); my $dt3 = DateTime->new( year => 2003, month => 6, day => 21, ); for (@data) { /(\w+),\s+(\w+)\s+(\d+)\s+(\d+)\s+(\w)\s+(\d+)\s+(\d+)\s+(\w)\s+sunrise:\s+(\d+:\d+:\d+)\s+sunset:\s+(\d+:\d+:\d+)/; if ( $5 eq 'N' ) { $lat = sprintf( "%.3f", ( $3 + ( $4 / 60 ) ) ); } elsif ( $5 eq 'S' ) { $lat = sprintf( "%.3f", -( $3 + ( $4 / 60 ) ) ); } if ( $8 eq 'E' ) { $long = sprintf( "%.3f", $6 + ( $7 / 60 ) ); } elsif ( $8 eq 'W' ) { $long = sprintf( "%.3f", -( $6 + ( $7 / 60 ) ) ); } if ( $long < 0 ) { $offset = DateTime::TimeZone::offset_as_string( ceil( $long / 15 ) * 60 * 60 ); } elsif ( $long > 0 ) { $offset = DateTime::TimeZone::offset_as_string( floor( $long / 15 ) * 60 * 60 ); } my $sunrise = DateTime::Event::Sunrise->sunrise( longitude => $long, latitude => $lat, upper_limb => 0, ); my $sunset = DateTime::Event::Sunrise->sunset( longitude => $long, latitude => $lat, upper_limb => 0, ); my $cloned_date = $dt3->clone(); $cloned_date->set_time_zone($offset); my $tmp_rise = $sunrise->next($cloned_date); my $tmp_set = $sunset->next($cloned_date); my $tmp_rise_lo = $tmp_rise->clone->add(seconds => - $fudge)->hms; my $tmp_rise_hi = $tmp_rise->clone->add(seconds => $fudge)->hms; my $tmp_set_lo = $tmp_set ->clone->add(seconds => - $fudge)->hms; my $tmp_set_hi = $tmp_set ->clone->add(seconds => $fudge)->hms; ok(($tmp_rise_lo lt $9) && ($9 lt $tmp_rise_hi), "sunrise for $1, $2"); ok(($tmp_set_lo lt $10) && ($10 lt $tmp_set_hi), "sunset for $1, $2"); } # # The data below have been prepared by a C program which includes # Paul Schlyter's code. Therefore, what is tested is the compatibility # of the Perl code with the C code. # # See how this C program is generated in # https://github.com/jforget/Astro-Sunrise/blob/master/util/mktest-01d # sub data { return split "\n", <<'DATA'; Aberdeen, Scotland 57 9 N 2 9 W sunrise: 03:12:22 sunset: 21:08:11 Adelaide, Australia 34 55 S 138 36 E sunrise: 06:53:01 sunset: 16:41:22 Algiers, Algeria 36 50 N 3 0 E sunrise: 04:29:04 sunset: 19:10:17 Amsterdam, Netherlands 52 22 N 4 53 E sunrise: 03:18:01 sunset: 20:06:16 Ankara, Turkey 39 55 N 32 55 E sunrise: 04:19:49 sunset: 19:20:09 Asuncion, Paraguay 25 15 S 57 40 W sunrise: 07:35:29 sunset: 18:09:17 Athens, Greece 37 58 N 23 43 E sunrise: 04:02:47 sunset: 18:50:48 Auckland, New_Zealand 36 52 S 174 45 E sunrise: 06:33:40 sunset: 16:11:28 Bangkok, Thailand 13 45 N 100 30 E sunrise: 04:51:29 sunset: 17:47:44 Barcelona, Spain 41 23 N 2 9 E sunrise: 04:17:59 sunset: 19:28:10 Beijing, China 39 55 N 116 25 E sunrise: 03:45:46 sunset: 18:46:06 Belem, Brazil 1 28 S 48 29 W sunrise: 06:14:33 sunset: 18:16:43 Belfast, Northern_Ireland 54 37 N 5 56 W sunrise: 03:46:54 sunset: 21:03:55 Belgrade, Yugoslavia 44 52 N 20 32 E sunrise: 03:51:33 sunset: 19:27:30 Berlin, Germany 52 30 N 13 25 E sunrise: 02:43:05 sunset: 19:32:55 Birmingham, England 52 25 N 1 55 W sunrise: 03:44:55 sunset: 20:33:46 Bogota, Colombia 4 32 N 74 15 W sunrise: 06:47:12 sunset: 19:10:15 Bombay, India 19 0 N 72 48 E sunrise: 04:32:12 sunset: 17:48:39 Bordeaux, France 44 50 N 0 31 W sunrise: 04:15:54 sunset: 19:51:35 Bremen, Germany 53 5 N 8 49 E sunrise: 02:57:56 sunset: 19:54:52 Brisbane, Australia 27 29 S 153 8 E sunrise: 06:36:59 sunset: 17:01:07 Bristol, England 51 28 N 2 35 W sunrise: 03:53:03 sunset: 20:30:58 Brussels, Belgium 50 52 N 4 22 E sunrise: 03:28:33 sunset: 19:59:51 Bucharest, Romania 44 25 N 26 7 E sunrise: 03:30:59 sunset: 19:03:23 Budapest, Hungary 47 30 N 19 5 E sunrise: 03:46:14 sunset: 19:44:25 Buenos_Aires, Argentina 34 35 S 58 22 W sunrise: 08:00:08 sunset: 17:50:13 Cairo, Egypt 30 2 N 31 21 E sunrise: 04:53:51 sunset: 18:58:39 Calcutta, India 22 34 N 88 24 E sunrise: 04:22:30 sunset: 17:53:33 Canton, China 23 7 N 113 15 E sunrise: 04:41:55 sunset: 18:15:17 Cape_Town, South_Africa 33 55 S 18 22 E sunrise: 06:51:26 sunset: 16:44:58 Caracas, Venezuela 10 28 N 67 2 W sunrise: 06:07:46 sunset: 18:51:56 Cayenne, French_Guiana 4 49 N 52 18 W sunrise: 06:18:53 sunset: 18:42:56 Chihuahua, Mexico 28 37 N 106 5 W sunrise: 05:07:04 sunset: 19:05:04 Chongqing, China 29 46 N 106 34 E sunrise: 04:53:35 sunset: 18:57:06 Copenhagen, Denmark 55 40 N 12 34 E sunrise: 02:25:20 sunset: 19:57:28 Cordoba, Argentina 31 28 S 64 10 W sunrise: 07:15:31 sunset: 17:21:14 Dakar, Senegal 14 40 N 17 28 W sunrise: 05:41:42 sunset: 18:41:24 Darwin, Australia 12 28 S 130 51 E sunrise: 05:36:28 sunset: 16:59:56 Djibouti, Djibouti 11 30 N 43 3 E sunrise: 04:45:29 sunset: 17:33:25 Dublin, Ireland 53 20 N 6 15 W sunrise: 03:56:39 sunset: 20:56:43 Durban, South_Africa 29 53 S 30 53 E sunrise: 06:51:31 sunset: 17:04:44 Edinburgh, Scotland 55 55 N 3 10 W sunrise: 03:26:23 sunset: 21:02:18 Frankfurt, Germany 50 7 N 8 41 E sunrise: 03:15:14 sunset: 19:38:38 Georgetown, Guyana 6 45 N 58 15 W sunrise: 06:39:17 sunset: 19:10:08 Glasgow, Scotland 55 50 N 4 15 W sunrise: 03:31:21 sunset: 21:06:00 Guatemala_City, Guatemala 14 37 N 90 31 W sunrise: 05:34:03 sunset: 18:33:33 Guayaquil, Ecuador 2 10 S 79 56 W sunrise: 06:21:35 sunset: 18:21:20 Hamburg, Germany 53 33 N 10 2 E sunrise: 02:50:07 sunset: 19:52:57 Havana, Cuba 23 8 N 82 23 W sunrise: 05:44:32 sunset: 19:17:59 Helsinki, Finland 60 10 N 25 0 E sunrise: 01:53:43 sunset: 20:49:36 Hobart, Tasmania 42 52 S 147 19 E sunrise: 06:41:50 sunset: 15:42:48 Iquique, Chile 20 10 S 70 7 W sunrise: 07:14:55 sunset: 18:09:27 Irkutsk, Russia 52 30 N 104 20 E sunrise: 02:39:22 sunset: 19:29:11 Jakarta, Indonesia 6 16 S 106 48 E sunrise: 06:01:40 sunset: 17:47:09 Johannesburg, South_Africa 26 12 S 28 4 E sunrise: 05:54:31 sunset: 16:24:15 Kingston, Jamaica 17 59 N 76 49 W sunrise: 05:32:46 sunset: 18:45:12 Kinshasa, Congo 4 18 S 15 17 E sunrise: 06:04:22 sunset: 17:56:42 La_Paz, Bolivia 16 27 S 68 22 W sunrise: 07:00:47 sunset: 18:09:35 Leeds, England 53 45 N 1 30 W sunrise: 03:34:58 sunset: 20:40:22 Lima, Peru 12 0 S 77 2 W sunrise: 06:27:17 sunset: 17:52:26 Lisbon, Portugal 38 44 N 9 9 W sunrise: 05:11:54 sunset: 20:04:40 Liverpool, England 53 25 N 3 0 W sunrise: 03:43:07 sunset: 20:44:14 London, England 51 32 N 0 5 W sunrise: 03:42:41 sunset: 20:21:20 Lyons, France 45 45 N 4 50 E sunrise: 03:50:47 sunset: 19:33:53 Madrid, Spain 40 26 N 3 42 W sunrise: 04:44:36 sunset: 19:48:21 Manchester, England 53 30 N 2 15 W sunrise: 03:39:35 sunset: 20:41:46 Manila, Philippines 14 35 N 120 57 E sunrise: 05:28:07 sunset: 18:27:29 Marseilles, France 43 20 N 5 20 E sunrise: 03:58:16 sunset: 19:22:25 Mazatlan, Mexico 23 12 N 106 25 W sunrise: 05:20:33 sunset: 18:54:16 Mecca, Saudi_Arabia 21 29 N 39 45 E sunrise: 04:39:23 sunset: 18:05:55 Melbourne, Australia 37 47 S 144 58 E sunrise: 06:35:24 sunset: 16:08:02 Mexico_City, Mexico 19 26 N 99 7 W sunrise: 05:59:06 sunset: 19:17:18 Milan, Italy 45 27 N 9 10 E sunrise: 03:34:41 sunset: 19:15:19 Montevideo, Uruguay 34 53 S 56 10 W sunrise: 07:52:07 sunset: 17:40:38 Moscow, Russia 55 45 N 37 36 E sunrise: 02:44:33 sunset: 20:17:57 Munich, Germany 48 8 N 11 35 E sunrise: 03:13:21 sunset: 19:17:19 Nagasaki, Japan 32 48 N 129 57 E sunrise: 04:12:23 sunset: 18:31:12 Nagoya, Japan 35 7 N 136 56 E sunrise: 04:38:11 sunset: 19:09:32 Nairobi, Kenya 1 25 S 36 55 E sunrise: 05:32:48 sunset: 17:35:09 Nanjing_Nanking, China 32 3 N 118 53 E sunrise: 03:58:37 sunset: 18:13:32 Naples, Italy 40 50 N 14 15 E sunrise: 03:31:27 sunset: 18:37:53 Newcastle_on_Tyne, England 54 58 N 1 37 W sunrise: 03:27:11 sunset: 20:49:06 Odessa, Ukraine 46 27 N 30 48 E sunrise: 04:03:58 sunset: 19:52:57 Osaka, Japan 34 32 N 135 30 E sunrise: 04:45:32 sunset: 19:13:39 Oslo, Norway 59 57 N 10 42 E sunrise: 01:53:27 sunset: 20:44:17 Panama_City, Panama 8 58 N 79 32 W sunrise: 06:00:28 sunset: 18:39:14 Paramaribo, Suriname 5 45 N 55 15 W sunrise: 06:29:03 sunset: 18:56:22 Paris, France 48 48 N 2 20 E sunrise: 03:47:12 sunset: 19:57:29 Perth, Australia 31 57 S 115 52 E sunrise: 06:16:27 sunset: 16:19:49 Plymouth, England 50 25 N 4 5 W sunrise: 04:04:45 sunset: 20:31:16 Port_Moresby, Papua_New_Guinea 9 25 S 147 8 E sunrise: 05:25:51 sunset: 17:00:15 Prague, Czech_Republic 50 5 N 14 26 E sunrise: 02:52:25 sunset: 19:15:27 Rangoon, Myanmar 16 50 N 96 0 E sunrise: 05:03:38 sunset: 18:11:36 Reykjavik, Iceland 64 4 N 21 58 W sunrise: 01:57:12 sunset: 23:01:55 Rio_de_Janeiro, Brazil 22 57 S 43 12 W sunrise: 07:32:48 sunset: 18:16:11 Rome, Italy 41 54 N 12 27 E sunrise: 03:34:59 sunset: 18:48:45 Salvador, Brazil 12 56 S 38 27 W sunrise: 06:54:37 sunset: 18:16:23 Santiago, Chile 33 28 S 70 45 W sunrise: 07:46:48 sunset: 17:42:38 St_Petersburg, Russia 59 56 N 30 18 E sunrise: 02:35:14 sunset: 21:25:41 Sao_Paulo, Brazil 23 31 S 46 31 W sunrise: 06:47:15 sunset: 17:28:18 Shanghai, China 31 10 N 121 28 E sunrise: 04:50:31 sunset: 19:00:57 Singapore, Singapore 1 14 N 103 55 E sunrise: 05:00:10 sunset: 17:11:43 Sofia, Bulgaria 42 40 N 23 20 E sunrise: 03:48:42 sunset: 19:07:57 Stockholm, Sweden 59 17 N 18 3 E sunrise: 02:31:22 sunset: 21:07:34 Sydney, Australia 34 0 S 151 0 E sunrise: 07:01:01 sunset: 16:54:08 Tananarive, Madagascar 18 50 S 47 33 E sunrise: 06:21:35 sunset: 17:21:18 Teheran, Iran 35 45 N 51 45 E sunrise: 04:17:10 sunset: 18:52:07 Tokyo, Japan 35 40 N 139 45 E sunrise: 04:25:22 sunset: 18:59:49 Tripoli, Libya 32 57 N 13 12 E sunrise: 03:59:04 sunset: 18:18:40 Venice, Italy 45 26 N 12 20 E sunrise: 03:22:05 sunset: 19:02:35 Veracruz, Mexico 19 10 N 96 10 W sunrise: 05:47:50 sunset: 19:04:58 Vienna, Austria 48 14 N 16 20 E sunrise: 03:53:53 sunset: 19:58:47 Vladivostok, Russia 43 10 N 132 0 E sunrise: 03:32:08 sunset: 18:55:03 Warsaw, Poland 52 14 N 21 0 E sunrise: 03:14:19 sunset: 20:01:00 Wellington, New_Zealand 41 17 S 174 47 E sunrise: 06:46:43 sunset: 15:58:09 Zurich, Switzerland 47 21 N 8 31 E sunrise: 03:29:11 sunset: 19:26:01 DATA } DateTime-Event-Sunrise-0.0505/t/06checks.t0000644000175000017500000000507512364262511015633 0ustar jfjf# -*- encoding: utf-8; indent-tabs-mode: nil -*- # # Test script for DateTime::Event::Sunrise # Copyright (C) 2014 Jean Forget # # This program is distributed under the same terms as Perl 5.16.3: # GNU Public License version 1 or later and Perl Artistic License # # You can find the text of the licenses in the F file or at # L # and L. # # Here is the summary of GPL: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # # # Checking the value checks. # use Test::More; use Test::Exception; use DateTime::Event::Sunrise; plan(tests => 12); # 1 dies_ok { DateTime::Event::Sunrise->new( longitude => 0, 1 ) } "Odd number of parameters"; # 2 dies_ok { DateTime::Event::Sunrise->new( precise => 1, iteration => 1) } "Parameter 'iteration' is deprecated, use only 'precise'"; my $sun = DateTime::Event::Sunrise->new (); # with all the default values! # 3 dies_ok { my $s = $sun->sunset_datetime("illegal") } "Dates need to be DateTime objects"; # 4 dies_ok { my $s = $sun->sunrise_datetime("illegal") } "Dates need to be DateTime objects"; # 5 dies_ok { my $s = $sun->sunrise_sunset_span("illegal") } "Dates need to be DateTime objects"; # 6 dies_ok { my $s = $sun->is_polar_night("illegal") } "Dates need to be DateTime objects"; # 7 dies_ok { my $s = $sun->is_polar_day("illegal") } "Dates need to be DateTime objects"; # 8 dies_ok { my $s = $sun->is_day_and_night("illegal") } "Dates need to be DateTime objects"; # 9 dies_ok { my $s = $sun->_following_sunrise("illegal") } "Dates need to be DateTime objects"; # 10 dies_ok { my $s = $sun->_previous_sunrise("illegal") } "Dates need to be DateTime objects"; # 11 dies_ok { my $s = $sun->_following_sunset("illegal") } "Dates need to be DateTime objects"; # 12 dies_ok { my $s = $sun->_previous_sunset("illegal") } "Dates need to be DateTime objects"; DateTime-Event-Sunrise-0.0505/t/05polar.t0000644000175000017500000005571012320603624015504 0ustar jfjf# -*- encoding: utf-8; indent-tabs-mode: nil -*- # # Test script for DateTime::Event::Sunrise # Copyright (C) 2014 Ron Hill and Jean Forget # # This program is distributed under the same terms as Perl 5.16.3: # GNU Public License version 1 or later and Perl Artistic License # # You can find the text of the licenses in the F file or at # L # and L. # # Here is the summary of GPL: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # use strict; use POSIX qw(floor ceil); use Test::More; use DateTime; use DateTime::Duration; use DateTime::Event::Sunrise; my @data = data(); plan tests => 5 * @data; my $fudge = 2; for (@data) { my ($yyyy, $mm, $dd, $city, $ltd, $ltm, $ltc, $lgd, $lgm, $lgc, $altitude, $upper_limb, $pn, $dn, $pd, $result) = $_ =~ /^(\d{4})\s+(\d\d?)\s+(\d\d?) \s+(\w+) \s+(\d+)\s+(\d+)\s+(\w) \s+(\d+)\s+(\d+)\s+(\w) \s+([-.0-9]+) \s+([01]) \s+([01]) \s+([01]) \s+([01]) \s+(.*?)$/x; my ($lat, $long, $offset, $expected_rise_low, $expected_rise_high, $expected_set_low, $expected_set_high); if ($result =~ /sunrise: ([-0-9]{2}):(\d\d):(\d\d)\s+sunset:\s+(\d\d):(\d\d):(\d\d)/) { my ($hh1, $mm1, $ss1, $hh2, $mm2, $ss2) = ($1, $2, $3, $4, $5, $6); $expected_rise_low = DateTime->new(year => $yyyy, month => $mm, day => $dd) + DateTime::Duration->new(hours => $hh1, minutes => $mm1, seconds => $ss1 - $fudge); $expected_rise_high = DateTime->new(year => $yyyy, month => $mm, day => $dd) + DateTime::Duration->new(hours => $hh1, minutes => $mm1, seconds => $ss1 + $fudge); $expected_set_low = DateTime->new(year => $yyyy, month => $mm, day => $dd) + DateTime::Duration->new(hours => $hh2, minutes => $mm2, seconds => $ss2 - $fudge); $expected_set_high = DateTime->new(year => $yyyy, month => $mm, day => $dd) + DateTime::Duration->new(hours => $hh2, minutes => $mm2, seconds => $ss2 + $fudge); } if ( $ltc eq 'N' ) { $lat = sprintf("%.3f", $ltd + $ltm / 60); } elsif ( $ltc eq 'S' ) { $lat = sprintf("%.3f", -($ltd + $ltm / 60)); } if ( $lgc eq 'E' ) { $long = sprintf("%.3f", $lgd + $lgm / 60); } elsif ( $lgc eq 'W' ) { $long = sprintf("%.3f", -($lgd + $lgm / 60)); } if ( $long < 0 ) { $offset = DateTime::TimeZone::offset_as_string( ceil( $long / 15 ) * 60 * 60 ); } else { $offset = DateTime::TimeZone::offset_as_string( floor( $long / 15 ) * 60 * 60 ); } my $sunrise = DateTime::Event::Sunrise->new( longitude => $long, latitude => $lat, altitude => $altitude, upper_limb => $upper_limb, silent => 1, ); #my $dt = DateTime->new(year => $yyyy, month => $mm, day => $dd, time_zone => $offset); my $dt = DateTime->new(year => $yyyy, month => $mm, day => $dd); my $tmp_rise = $sunrise->sunrise_datetime($dt); my $tmp_set = $sunrise->sunset_datetime ($dt); my $sun_rise = $tmp_rise->strftime("%H:%M"); my $sun_set = $tmp_set->strftime("%H:%M"); ok( $tmp_rise >= $expected_rise_low && $tmp_rise <= $expected_rise_high, join ' ', "Sunrise for $city", $tmp_rise->ymd, $expected_rise_low->hms, $tmp_rise->hms, $expected_rise_high->hms, $upper_limb, $altitude); ok( $tmp_set >= $expected_set_low && $tmp_set <= $expected_set_high, join ' ', "Sunset for $city", $tmp_set->ymd, $expected_set_low->hms, $tmp_set->hms, $expected_set_high->hms, $upper_limb, $altitude); is (0 + $sunrise->is_polar_night ($dt), $pn); is (0 + $sunrise->is_day_and_night($dt), $dn); is (0 + $sunrise->is_polar_day ($dt), $pd); } # # The data below have been prepared by a C program which includes # Paul Schlyter's code. Therefore, what is tested is the compatibility # of the Perl code with the C code. # # See how this C program is generated in # https://github.com/jforget/Astro-Sunrise/blob/master/util/mktest-05 # # sub data { return split "\n", <<'DATA'; 2013 1 1 North_Pole 89 59 N 0 0 E 0 0 1 0 0 sunrise: 12:03:40 sunset: 12:03:40 2013 1 1 North_Pole 89 59 N 0 0 E 0 1 1 0 0 sunrise: 12:03:40 sunset: 12:03:40 2013 1 1 North_Pole 89 59 N 0 0 E -0.583 0 1 0 0 sunrise: 12:03:40 sunset: 12:03:40 2013 1 1 North_Pole 89 59 N 0 0 E -0.583 1 1 0 0 sunrise: 12:03:40 sunset: 12:03:40 2013 1 1 North_Pole 89 59 N 0 0 E -0.833 0 1 0 0 sunrise: 12:03:40 sunset: 12:03:40 2013 1 1 North_Pole 89 59 N 0 0 E -0.833 1 1 0 0 sunrise: 12:03:40 sunset: 12:03:40 2013 1 1 North_Pole 89 59 N 0 0 E -12 0 1 0 0 sunrise: 12:03:40 sunset: 12:03:40 2013 1 1 North_Pole 89 59 N 0 0 E -12 1 1 0 0 sunrise: 12:03:40 sunset: 12:03:40 2013 1 1 North_Pole 89 59 N 0 0 E -18 0 1 0 0 sunrise: 12:03:40 sunset: 12:03:40 2013 1 1 North_Pole 89 59 N 0 0 E -18 1 1 0 0 sunrise: 12:03:40 sunset: 12:03:40 2013 3 21 North_Pole 89 59 N 0 0 E 0 0 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 North_Pole 89 59 N 0 0 E 0 1 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 North_Pole 89 59 N 0 0 E -0.583 0 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 North_Pole 89 59 N 0 0 E -0.583 1 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 North_Pole 89 59 N 0 0 E -0.833 0 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 North_Pole 89 59 N 0 0 E -0.833 1 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 North_Pole 89 59 N 0 0 E -12 0 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 North_Pole 89 59 N 0 0 E -12 1 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 North_Pole 89 59 N 0 0 E -18 0 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 North_Pole 89 59 N 0 0 E -18 1 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 6 21 North_Pole 89 59 N 0 0 E 0 0 0 0 1 sunrise: 00:01:49 sunset: 24:01:49 2013 6 21 North_Pole 89 59 N 0 0 E 0 1 0 0 1 sunrise: 00:01:49 sunset: 24:01:49 2013 6 21 North_Pole 89 59 N 0 0 E -0.583 0 0 0 1 sunrise: 00:01:49 sunset: 24:01:49 2013 6 21 North_Pole 89 59 N 0 0 E -0.583 1 0 0 1 sunrise: 00:01:49 sunset: 24:01:49 2013 6 21 North_Pole 89 59 N 0 0 E -0.833 0 0 0 1 sunrise: 00:01:49 sunset: 24:01:49 2013 6 21 North_Pole 89 59 N 0 0 E -0.833 1 0 0 1 sunrise: 00:01:49 sunset: 24:01:49 2013 6 21 North_Pole 89 59 N 0 0 E -12 0 0 0 1 sunrise: 00:01:49 sunset: 24:01:49 2013 6 21 North_Pole 89 59 N 0 0 E -12 1 0 0 1 sunrise: 00:01:49 sunset: 24:01:49 2013 6 21 North_Pole 89 59 N 0 0 E -18 0 0 0 1 sunrise: 00:01:49 sunset: 24:01:49 2013 6 21 North_Pole 89 59 N 0 0 E -18 1 0 0 1 sunrise: 00:01:49 sunset: 24:01:49 2013 8 31 North_Pole 89 59 N 0 0 E 0 0 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 North_Pole 89 59 N 0 0 E 0 1 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 North_Pole 89 59 N 0 0 E -0.583 0 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 North_Pole 89 59 N 0 0 E -0.583 1 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 North_Pole 89 59 N 0 0 E -0.833 0 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 North_Pole 89 59 N 0 0 E -0.833 1 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 North_Pole 89 59 N 0 0 E -12 0 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 North_Pole 89 59 N 0 0 E -12 1 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 North_Pole 89 59 N 0 0 E -18 0 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 North_Pole 89 59 N 0 0 E -18 1 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 9 21 North_Pole 89 59 N 0 0 E 0 0 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 North_Pole 89 59 N 0 0 E 0 1 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 North_Pole 89 59 N 0 0 E -0.583 0 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 North_Pole 89 59 N 0 0 E -0.583 1 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 North_Pole 89 59 N 0 0 E -0.833 0 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 North_Pole 89 59 N 0 0 E -0.833 1 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 North_Pole 89 59 N 0 0 E -12 0 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 North_Pole 89 59 N 0 0 E -12 1 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 North_Pole 89 59 N 0 0 E -18 0 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 North_Pole 89 59 N 0 0 E -18 1 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 12 31 North_Pole 89 59 N 0 0 E 0 0 1 0 0 sunrise: 12:03:05 sunset: 12:03:05 2013 12 31 North_Pole 89 59 N 0 0 E 0 1 1 0 0 sunrise: 12:03:05 sunset: 12:03:05 2013 12 31 North_Pole 89 59 N 0 0 E -0.583 0 1 0 0 sunrise: 12:03:05 sunset: 12:03:05 2013 12 31 North_Pole 89 59 N 0 0 E -0.583 1 1 0 0 sunrise: 12:03:05 sunset: 12:03:05 2013 12 31 North_Pole 89 59 N 0 0 E -0.833 0 1 0 0 sunrise: 12:03:05 sunset: 12:03:05 2013 12 31 North_Pole 89 59 N 0 0 E -0.833 1 1 0 0 sunrise: 12:03:05 sunset: 12:03:05 2013 12 31 North_Pole 89 59 N 0 0 E -12 0 1 0 0 sunrise: 12:03:05 sunset: 12:03:05 2013 12 31 North_Pole 89 59 N 0 0 E -12 1 1 0 0 sunrise: 12:03:05 sunset: 12:03:05 2013 12 31 North_Pole 89 59 N 0 0 E -18 0 1 0 0 sunrise: 12:03:05 sunset: 12:03:05 2013 12 31 North_Pole 89 59 N 0 0 E -18 1 1 0 0 sunrise: 12:03:05 sunset: 12:03:05 2013 1 1 Halley_Base 75 35 S 26 39 W 0 0 0 0 1 sunrise: 01:50:18 sunset: 25:50:18 2013 1 1 Halley_Base 75 35 S 26 39 W 0 1 0 0 1 sunrise: 01:50:18 sunset: 25:50:18 2013 1 1 Halley_Base 75 35 S 26 39 W -0.583 0 0 0 1 sunrise: 01:50:18 sunset: 25:50:18 2013 1 1 Halley_Base 75 35 S 26 39 W -0.583 1 0 0 1 sunrise: 01:50:18 sunset: 25:50:18 2013 1 1 Halley_Base 75 35 S 26 39 W -0.833 0 0 0 1 sunrise: 01:50:18 sunset: 25:50:18 2013 1 1 Halley_Base 75 35 S 26 39 W -0.833 1 0 0 1 sunrise: 01:50:18 sunset: 25:50:18 2013 1 1 Halley_Base 75 35 S 26 39 W -12 0 0 0 1 sunrise: 01:50:18 sunset: 25:50:18 2013 1 1 Halley_Base 75 35 S 26 39 W -12 1 0 0 1 sunrise: 01:50:18 sunset: 25:50:18 2013 1 1 Halley_Base 75 35 S 26 39 W -18 0 0 0 1 sunrise: 01:50:18 sunset: 25:50:18 2013 1 1 Halley_Base 75 35 S 26 39 W -18 1 0 0 1 sunrise: 01:50:18 sunset: 25:50:18 2013 3 21 Halley_Base 75 35 S 26 39 W 0 0 0 1 0 sunrise: 08:00:34 sunset: 19:46:49 2013 3 21 Halley_Base 75 35 S 26 39 W 0 1 0 1 0 sunrise: 07:56:16 sunset: 19:51:07 2013 3 21 Halley_Base 75 35 S 26 39 W -0.583 0 0 1 0 sunrise: 07:51:12 sunset: 19:56:11 2013 3 21 Halley_Base 75 35 S 26 39 W -0.583 1 0 1 0 sunrise: 07:46:54 sunset: 20:00:29 2013 3 21 Halley_Base 75 35 S 26 39 W -0.833 0 0 1 0 sunrise: 07:47:11 sunset: 20:00:12 2013 3 21 Halley_Base 75 35 S 26 39 W -0.833 1 0 1 0 sunrise: 07:42:53 sunset: 20:04:30 2013 3 21 Halley_Base 75 35 S 26 39 W -12 0 0 1 0 sunrise: 04:19:13 sunset: 23:28:10 2013 3 21 Halley_Base 75 35 S 26 39 W -12 1 0 1 0 sunrise: 04:11:59 sunset: 23:35:24 2013 3 21 Halley_Base 75 35 S 26 39 W -18 0 0 0 1 sunrise: 01:53:42 sunset: 25:53:42 2013 3 21 Halley_Base 75 35 S 26 39 W -18 1 0 0 1 sunrise: 01:53:42 sunset: 25:53:42 2013 6 21 Halley_Base 75 35 S 26 39 W 0 0 1 0 0 sunrise: 13:48:26 sunset: 13:48:26 2013 6 21 Halley_Base 75 35 S 26 39 W 0 1 1 0 0 sunrise: 13:48:26 sunset: 13:48:26 2013 6 21 Halley_Base 75 35 S 26 39 W -0.583 0 1 0 0 sunrise: 13:48:26 sunset: 13:48:26 2013 6 21 Halley_Base 75 35 S 26 39 W -0.583 1 1 0 0 sunrise: 13:48:26 sunset: 13:48:26 2013 6 21 Halley_Base 75 35 S 26 39 W -0.833 0 1 0 0 sunrise: 13:48:26 sunset: 13:48:26 2013 6 21 Halley_Base 75 35 S 26 39 W -0.833 1 1 0 0 sunrise: 13:48:26 sunset: 13:48:26 2013 6 21 Halley_Base 75 35 S 26 39 W -12 0 0 1 0 sunrise: 11:12:05 sunset: 16:24:48 2013 6 21 Halley_Base 75 35 S 26 39 W -12 1 0 1 0 sunrise: 11:05:05 sunset: 16:31:47 2013 6 21 Halley_Base 75 35 S 26 39 W -18 0 0 1 0 sunrise: 09:06:23 sunset: 18:30:30 2013 6 21 Halley_Base 75 35 S 26 39 W -18 1 0 1 0 sunrise: 09:01:46 sunset: 18:35:07 2013 8 31 Halley_Base 75 35 S 26 39 W 0 0 0 1 0 sunrise: 10:08:00 sunset: 17:25:39 2013 8 31 Halley_Base 75 35 S 26 39 W 0 1 0 1 0 sunrise: 10:02:47 sunset: 17:30:52 2013 8 31 Halley_Base 75 35 S 26 39 W -0.583 0 0 1 0 sunrise: 09:56:36 sunset: 17:37:03 2013 8 31 Halley_Base 75 35 S 26 39 W -0.583 1 0 1 0 sunrise: 09:51:33 sunset: 17:42:06 2013 8 31 Halley_Base 75 35 S 26 39 W -0.833 0 0 1 0 sunrise: 09:51:49 sunset: 17:41:50 2013 8 31 Halley_Base 75 35 S 26 39 W -0.833 1 0 1 0 sunrise: 09:46:50 sunset: 17:46:49 2013 8 31 Halley_Base 75 35 S 26 39 W -12 0 0 1 0 sunrise: 06:45:01 sunset: 20:48:38 2013 8 31 Halley_Base 75 35 S 26 39 W -12 1 0 1 0 sunrise: 06:40:39 sunset: 20:53:00 2013 8 31 Halley_Base 75 35 S 26 39 W -18 0 0 1 0 sunrise: 04:56:24 sunset: 22:37:16 2013 8 31 Halley_Base 75 35 S 26 39 W -18 1 0 1 0 sunrise: 04:50:47 sunset: 22:42:52 2013 9 21 Halley_Base 75 35 S 26 39 W 0 0 0 1 0 sunrise: 07:47:21 sunset: 19:31:48 2013 9 21 Halley_Base 75 35 S 26 39 W 0 1 0 1 0 sunrise: 07:43:05 sunset: 19:36:04 2013 9 21 Halley_Base 75 35 S 26 39 W -0.583 0 0 1 0 sunrise: 07:37:59 sunset: 19:41:10 2013 9 21 Halley_Base 75 35 S 26 39 W -0.583 1 0 1 0 sunrise: 07:33:43 sunset: 19:45:26 2013 9 21 Halley_Base 75 35 S 26 39 W -0.833 0 0 1 0 sunrise: 07:33:58 sunset: 19:45:11 2013 9 21 Halley_Base 75 35 S 26 39 W -0.833 1 0 1 0 sunrise: 07:29:41 sunset: 19:49:27 2013 9 21 Halley_Base 75 35 S 26 39 W -12 0 0 1 0 sunrise: 04:06:36 sunset: 23:12:32 2013 9 21 Halley_Base 75 35 S 26 39 W -12 1 0 1 0 sunrise: 03:59:29 sunset: 23:19:39 2013 9 21 Halley_Base 75 35 S 26 39 W -18 0 0 0 1 sunrise: 01:39:34 sunset: 25:39:34 2013 9 21 Halley_Base 75 35 S 26 39 W -18 1 0 0 1 sunrise: 01:39:34 sunset: 25:39:34 2013 12 31 Halley_Base 75 35 S 26 39 W 0 0 0 0 1 sunrise: 01:49:43 sunset: 25:49:43 2013 12 31 Halley_Base 75 35 S 26 39 W 0 1 0 0 1 sunrise: 01:49:43 sunset: 25:49:43 2013 12 31 Halley_Base 75 35 S 26 39 W -0.583 0 0 0 1 sunrise: 01:49:43 sunset: 25:49:43 2013 12 31 Halley_Base 75 35 S 26 39 W -0.583 1 0 0 1 sunrise: 01:49:43 sunset: 25:49:43 2013 12 31 Halley_Base 75 35 S 26 39 W -0.833 0 0 0 1 sunrise: 01:49:43 sunset: 25:49:43 2013 12 31 Halley_Base 75 35 S 26 39 W -0.833 1 0 0 1 sunrise: 01:49:43 sunset: 25:49:43 2013 12 31 Halley_Base 75 35 S 26 39 W -12 0 0 0 1 sunrise: 01:49:43 sunset: 25:49:43 2013 12 31 Halley_Base 75 35 S 26 39 W -12 1 0 0 1 sunrise: 01:49:43 sunset: 25:49:43 2013 12 31 Halley_Base 75 35 S 26 39 W -18 0 0 0 1 sunrise: 01:49:43 sunset: 25:49:43 2013 12 31 Halley_Base 75 35 S 26 39 W -18 1 0 0 1 sunrise: 01:49:43 sunset: 25:49:43 2013 1 1 South_Pole 89 59 S 0 0 W 0 0 0 0 1 sunrise: 00:03:40 sunset: 24:03:40 2013 1 1 South_Pole 89 59 S 0 0 W 0 1 0 0 1 sunrise: 00:03:40 sunset: 24:03:40 2013 1 1 South_Pole 89 59 S 0 0 W -0.583 0 0 0 1 sunrise: 00:03:40 sunset: 24:03:40 2013 1 1 South_Pole 89 59 S 0 0 W -0.583 1 0 0 1 sunrise: 00:03:40 sunset: 24:03:40 2013 1 1 South_Pole 89 59 S 0 0 W -0.833 0 0 0 1 sunrise: 00:03:40 sunset: 24:03:40 2013 1 1 South_Pole 89 59 S 0 0 W -0.833 1 0 0 1 sunrise: 00:03:40 sunset: 24:03:40 2013 1 1 South_Pole 89 59 S 0 0 W -12 0 0 0 1 sunrise: 00:03:40 sunset: 24:03:40 2013 1 1 South_Pole 89 59 S 0 0 W -12 1 0 0 1 sunrise: 00:03:40 sunset: 24:03:40 2013 1 1 South_Pole 89 59 S 0 0 W -18 0 0 0 1 sunrise: 00:03:40 sunset: 24:03:40 2013 1 1 South_Pole 89 59 S 0 0 W -18 1 0 0 1 sunrise: 00:03:40 sunset: 24:03:40 2013 3 21 South_Pole 89 59 S 0 0 W 0 0 1 0 0 sunrise: 12:07:07 sunset: 12:07:07 2013 3 21 South_Pole 89 59 S 0 0 W 0 1 1 0 0 sunrise: 12:07:07 sunset: 12:07:07 2013 3 21 South_Pole 89 59 S 0 0 W -0.583 0 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 South_Pole 89 59 S 0 0 W -0.583 1 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 South_Pole 89 59 S 0 0 W -0.833 0 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 South_Pole 89 59 S 0 0 W -0.833 1 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 South_Pole 89 59 S 0 0 W -12 0 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 South_Pole 89 59 S 0 0 W -12 1 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 South_Pole 89 59 S 0 0 W -18 0 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 3 21 South_Pole 89 59 S 0 0 W -18 1 0 0 1 sunrise: 00:07:07 sunset: 24:07:07 2013 6 21 South_Pole 89 59 S 0 0 W 0 0 1 0 0 sunrise: 12:01:49 sunset: 12:01:49 2013 6 21 South_Pole 89 59 S 0 0 W 0 1 1 0 0 sunrise: 12:01:49 sunset: 12:01:49 2013 6 21 South_Pole 89 59 S 0 0 W -0.583 0 1 0 0 sunrise: 12:01:49 sunset: 12:01:49 2013 6 21 South_Pole 89 59 S 0 0 W -0.583 1 1 0 0 sunrise: 12:01:49 sunset: 12:01:49 2013 6 21 South_Pole 89 59 S 0 0 W -0.833 0 1 0 0 sunrise: 12:01:49 sunset: 12:01:49 2013 6 21 South_Pole 89 59 S 0 0 W -0.833 1 1 0 0 sunrise: 12:01:49 sunset: 12:01:49 2013 6 21 South_Pole 89 59 S 0 0 W -12 0 1 0 0 sunrise: 12:01:49 sunset: 12:01:49 2013 6 21 South_Pole 89 59 S 0 0 W -12 1 1 0 0 sunrise: 12:01:49 sunset: 12:01:49 2013 6 21 South_Pole 89 59 S 0 0 W -18 0 1 0 0 sunrise: 12:01:49 sunset: 12:01:49 2013 6 21 South_Pole 89 59 S 0 0 W -18 1 1 0 0 sunrise: 12:01:49 sunset: 12:01:49 2013 8 31 South_Pole 89 59 S 0 0 W 0 0 1 0 0 sunrise: 12:00:15 sunset: 12:00:15 2013 8 31 South_Pole 89 59 S 0 0 W 0 1 1 0 0 sunrise: 12:00:15 sunset: 12:00:15 2013 8 31 South_Pole 89 59 S 0 0 W -0.583 0 1 0 0 sunrise: 12:00:15 sunset: 12:00:15 2013 8 31 South_Pole 89 59 S 0 0 W -0.583 1 1 0 0 sunrise: 12:00:15 sunset: 12:00:15 2013 8 31 South_Pole 89 59 S 0 0 W -0.833 0 1 0 0 sunrise: 12:00:15 sunset: 12:00:15 2013 8 31 South_Pole 89 59 S 0 0 W -0.833 1 1 0 0 sunrise: 12:00:15 sunset: 12:00:15 2013 8 31 South_Pole 89 59 S 0 0 W -12 0 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 South_Pole 89 59 S 0 0 W -12 1 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 South_Pole 89 59 S 0 0 W -18 0 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 8 31 South_Pole 89 59 S 0 0 W -18 1 0 0 1 sunrise: 00:00:15 sunset: 24:00:15 2013 9 21 South_Pole 89 59 S 0 0 W 0 0 1 0 0 sunrise: 11:53:00 sunset: 11:53:00 2013 9 21 South_Pole 89 59 S 0 0 W 0 1 1 0 0 sunrise: 11:53:00 sunset: 11:53:00 2013 9 21 South_Pole 89 59 S 0 0 W -0.583 0 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 South_Pole 89 59 S 0 0 W -0.583 1 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 South_Pole 89 59 S 0 0 W -0.833 0 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 South_Pole 89 59 S 0 0 W -0.833 1 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 South_Pole 89 59 S 0 0 W -12 0 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 South_Pole 89 59 S 0 0 W -12 1 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 South_Pole 89 59 S 0 0 W -18 0 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 9 21 South_Pole 89 59 S 0 0 W -18 1 0 0 1 sunrise: -1:53:00 sunset: 23:53:00 2013 12 31 South_Pole 89 59 S 0 0 W 0 0 0 0 1 sunrise: 00:03:05 sunset: 24:03:05 2013 12 31 South_Pole 89 59 S 0 0 W 0 1 0 0 1 sunrise: 00:03:05 sunset: 24:03:05 2013 12 31 South_Pole 89 59 S 0 0 W -0.583 0 0 0 1 sunrise: 00:03:05 sunset: 24:03:05 2013 12 31 South_Pole 89 59 S 0 0 W -0.583 1 0 0 1 sunrise: 00:03:05 sunset: 24:03:05 2013 12 31 South_Pole 89 59 S 0 0 W -0.833 0 0 0 1 sunrise: 00:03:05 sunset: 24:03:05 2013 12 31 South_Pole 89 59 S 0 0 W -0.833 1 0 0 1 sunrise: 00:03:05 sunset: 24:03:05 2013 12 31 South_Pole 89 59 S 0 0 W -12 0 0 0 1 sunrise: 00:03:05 sunset: 24:03:05 2013 12 31 South_Pole 89 59 S 0 0 W -12 1 0 0 1 sunrise: 00:03:05 sunset: 24:03:05 2013 12 31 South_Pole 89 59 S 0 0 W -18 0 0 0 1 sunrise: 00:03:05 sunset: 24:03:05 2013 12 31 South_Pole 89 59 S 0 0 W -18 1 0 0 1 sunrise: 00:03:05 sunset: 24:03:05 DATA } DateTime-Event-Sunrise-0.0505/t/04basic.t0000644000175000017500000010101512230027642015435 0ustar jfjf# -*- encoding: utf-8; indent-tabs-mode: nil -*- # # Test script for DateTime::Event::Sunrise # Copyright (C) 2013 Ron Hill and Jean Forget # # This program is distributed under the same terms as Perl 5.16.3: # GNU Public License version 1 or later and Perl Artistic License # # You can find the text of the licenses in the F file or at # L # and L. # # Here is the summary of GPL: # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # use strict; use POSIX qw(floor ceil); use Test::More; use DateTime; use DateTime::Duration; use DateTime::Event::Sunrise; my @data = data(); plan tests => 2 * @data; my $fudge = 2; for (@data) { my ($yyyy, $mm, $dd, $city, $ltd, $ltm, $ltc, $lgd, $lgm, $lgc, $altitude, $upper_limb, $result) = $_ =~ /^(\d{4})\s+(\d\d?)\s+(\d\d?) \s+(\w+) \s+(\d+)\s+(\d+)\s+(\w) \s+(\d+)\s+(\d+)\s+(\w) \s+([-.0-9]+) \s+([01]) \s+(.*)$/x; my ($lat, $long, $offset, $expected_rise_low, $expected_rise_high, $expected_set_low, $expected_set_high); if ($result =~ /sunrise: (\d\d):(\d\d):(\d\d)\s+sunset:\s+(\d\d):(\d\d):(\d\d)/) { my ($hh1, $mm1, $ss1, $hh2, $mm2, $ss2) = ($1, $2, $3, $4, $5, $6); $expected_rise_low = DateTime->new(year => $yyyy, month => $mm, day => $dd) + DateTime::Duration->new(hours => $hh1, minutes => $mm1, seconds => $ss1 - $fudge); $expected_rise_high = DateTime->new(year => $yyyy, month => $mm, day => $dd) + DateTime::Duration->new(hours => $hh1, minutes => $mm1, seconds => $ss1 + $fudge); $expected_set_low = DateTime->new(year => $yyyy, month => $mm, day => $dd) + DateTime::Duration->new(hours => $hh2, minutes => $mm2, seconds => $ss2 - $fudge); $expected_set_high = DateTime->new(year => $yyyy, month => $mm, day => $dd) + DateTime::Duration->new(hours => $hh2, minutes => $mm2, seconds => $ss2 + $fudge); } if ( $ltc eq 'N' ) { $lat = sprintf("%.3f", $ltd + $ltm / 60); } elsif ( $ltc eq 'S' ) { $lat = sprintf("%.3f", -($ltd + $ltm / 60)); } if ( $lgc eq 'E' ) { $long = sprintf("%.3f", $lgd + $lgm / 60); } elsif ( $lgc eq 'W' ) { $long = sprintf("%.3f", -($lgd + $lgm / 60)); } if ( $long < 0 ) { $offset = DateTime::TimeZone::offset_as_string( ceil( $long / 15 ) * 60 * 60 ); } elsif ( $long > 0 ) { $offset = DateTime::TimeZone::offset_as_string( floor( $long / 15 ) * 60 * 60 ); } my $sunrise = DateTime::Event::Sunrise->new( longitude => $long, latitude => $lat, altitude => $altitude, upper_limb => $upper_limb, ); #my $dt = DateTime->new(year => $yyyy, month => $mm, day => $dd, time_zone => $offset); my $dt = DateTime->new(year => $yyyy, month => $mm, day => $dd); my $tmp_rise = $sunrise->sunrise_datetime($dt); my $tmp_set = $sunrise->sunset_datetime ($dt); my $sun_rise = $tmp_rise->strftime("%H:%M"); my $sun_set = $tmp_set->strftime("%H:%M"); ok( $tmp_rise >= $expected_rise_low && $tmp_rise <= $expected_rise_high, join ' ', "Sunrise for $city", $tmp_rise->ymd, $expected_rise_low->hms, $tmp_rise->hms, $expected_rise_high->hms, $upper_limb, $altitude); ok( $tmp_set >= $expected_set_low && $tmp_set <= $expected_set_high, join ' ', "Sunset for $city", $tmp_set->ymd, $expected_set_low->hms, $tmp_set->hms, $expected_set_high->hms, $upper_limb, $altitude); } # # The data below have been prepared by a C program which includes # Paul Schlyter's code. Therefore, what is tested is the compatibility # of the Perl code with the C code. # # See how this C program is generated in # https://github.com/jforget/Astro-Sunrise/blob/master/util/mktest-04 # # Why those locations? # Greenwich because it is located on the eponymous prime meridian # Reykjavik, because it is close to the Northern Arctic Circle, so it can be used to check polar night and midnight sun # Quito because it is near the prime parallel, better known as "equator" # El Hierro, because it is located on a former prime meridian # sub data { return split "\n", <<'DATA'; 2013 1 1 Greenwich 51 28 N 0 0 E 10 0 sunrise: 09:50:02 sunset: 14:17:18 2013 1 1 Greenwich 51 28 N 0 0 E 10 1 sunrise: 09:46:41 sunset: 14:20:39 2013 1 1 Greenwich 51 28 N 0 0 E 0 0 sunrise: 08:12:14 sunset: 15:55:06 2013 1 1 Greenwich 51 28 N 0 0 E 0 1 sunrise: 08:10:00 sunset: 15:57:19 2013 1 1 Greenwich 51 28 N 0 0 E -0.583 0 sunrise: 08:07:28 sunset: 15:59:52 2013 1 1 Greenwich 51 28 N 0 0 E -0.583 1 sunrise: 08:05:16 sunset: 16:02:04 2013 1 1 Greenwich 51 28 N 0 0 E -0.833 0 sunrise: 08:05:26 sunset: 16:01:54 2013 1 1 Greenwich 51 28 N 0 0 E -0.833 1 sunrise: 08:03:15 sunset: 16:04:05 2013 1 1 Greenwich 51 28 N 0 0 E -12 0 sunrise: 06:42:43 sunset: 17:24:37 2013 1 1 Greenwich 51 28 N 0 0 E -12 1 sunrise: 06:40:50 sunset: 17:26:29 2013 1 1 Greenwich 51 28 N 0 0 E -18 0 sunrise: 06:02:08 sunset: 18:05:12 2013 1 1 Greenwich 51 28 N 0 0 E -18 1 sunrise: 06:00:20 sunset: 18:07:00 2013 1 1 Reykjavik 64 4 N 21 58 W 10 0 sunrise: 13:31:34 sunset: 13:31:34 polar night or midnight sun 2013 1 1 Reykjavik 64 4 N 21 58 W 10 1 sunrise: 13:31:34 sunset: 13:31:34 polar night or midnight sun 2013 1 1 Reykjavik 64 4 N 21 58 W 0 0 sunrise: 11:33:53 sunset: 15:29:14 2013 1 1 Reykjavik 64 4 N 21 58 W 0 1 sunrise: 11:28:31 sunset: 15:34:36 2013 1 1 Reykjavik 64 4 N 21 58 W -0.583 0 sunrise: 11:22:35 sunset: 15:40:32 2013 1 1 Reykjavik 64 4 N 21 58 W -0.583 1 sunrise: 11:17:37 sunset: 15:45:30 2013 1 1 Reykjavik 64 4 N 21 58 W -0.833 0 sunrise: 11:18:00 sunset: 15:45:07 2013 1 1 Reykjavik 64 4 N 21 58 W -0.833 1 sunrise: 11:13:11 sunset: 15:49:56 2013 1 1 Reykjavik 64 4 N 21 58 W -12 0 sunrise: 08:54:40 sunset: 18:08:27 2013 1 1 Reykjavik 64 4 N 21 58 W -12 1 sunrise: 08:51:52 sunset: 18:11:16 2013 1 1 Reykjavik 64 4 N 21 58 W -18 0 sunrise: 07:55:22 sunset: 19:07:46 2013 1 1 Reykjavik 64 4 N 21 58 W -18 1 sunrise: 07:52:47 sunset: 19:10:20 2013 1 1 Quito 0 15 S 78 35 W 10 0 sunrise: 12:01:09 sunset: 22:35:03 2013 1 1 Quito 0 15 S 78 35 W 10 1 sunrise: 11:59:58 sunset: 22:36:14 2013 1 1 Quito 0 15 S 78 35 W 0 0 sunrise: 11:17:41 sunset: 23:18:31 2013 1 1 Quito 0 15 S 78 35 W 0 1 sunrise: 11:16:30 sunset: 23:19:42 2013 1 1 Quito 0 15 S 78 35 W -0.583 0 sunrise: 11:15:09 sunset: 23:21:03 2013 1 1 Quito 0 15 S 78 35 W -0.583 1 sunrise: 11:13:58 sunset: 23:22:14 2013 1 1 Quito 0 15 S 78 35 W -0.833 0 sunrise: 11:14:03 sunset: 23:22:08 2013 1 1 Quito 0 15 S 78 35 W -0.833 1 sunrise: 11:12:53 sunset: 23:23:19 2013 1 1 Quito 0 15 S 78 35 W -12 0 sunrise: 10:25:28 sunset: 24:10:44 2013 1 1 Quito 0 15 S 78 35 W -12 1 sunrise: 10:24:17 sunset: 24:11:55 2013 1 1 Quito 0 15 S 78 35 W -18 0 sunrise: 09:59:13 sunset: 24:36:59 2013 1 1 Quito 0 15 S 78 35 W -18 1 sunrise: 09:58:02 sunset: 24:38:10 2013 1 1 El_Hierro 27 44 N 18 3 W 10 0 sunrise: 08:59:14 sunset: 17:32:33 2013 1 1 El_Hierro 27 44 N 18 3 W 10 1 sunrise: 08:57:46 sunset: 17:34:00 2013 1 1 El_Hierro 27 44 N 18 3 W 0 0 sunrise: 08:07:22 sunset: 18:24:25 2013 1 1 El_Hierro 27 44 N 18 3 W 0 1 sunrise: 08:06:00 sunset: 18:25:47 2013 1 1 El_Hierro 27 44 N 18 3 W -0.583 0 sunrise: 08:04:26 sunset: 18:27:21 2013 1 1 El_Hierro 27 44 N 18 3 W -0.583 1 sunrise: 08:03:04 sunset: 18:28:42 2013 1 1 El_Hierro 27 44 N 18 3 W -0.833 0 sunrise: 08:03:11 sunset: 18:28:36 2013 1 1 El_Hierro 27 44 N 18 3 W -0.833 1 sunrise: 08:01:49 sunset: 18:29:58 2013 1 1 El_Hierro 27 44 N 18 3 W -12 0 sunrise: 07:08:28 sunset: 19:23:19 2013 1 1 El_Hierro 27 44 N 18 3 W -12 1 sunrise: 07:07:10 sunset: 19:24:37 2013 1 1 El_Hierro 27 44 N 18 3 W -18 0 sunrise: 06:39:53 sunset: 19:51:53 2013 1 1 El_Hierro 27 44 N 18 3 W -18 1 sunrise: 06:38:36 sunset: 19:53:10 2013 3 21 Greenwich 51 28 N 0 0 E 10 0 sunrise: 07:09:42 sunset: 17:04:32 2013 3 21 Greenwich 51 28 N 0 0 E 10 1 sunrise: 07:07:57 sunset: 17:06:17 2013 3 21 Greenwich 51 28 N 0 0 E 0 0 sunrise: 06:05:03 sunset: 18:09:11 2013 3 21 Greenwich 51 28 N 0 0 E 0 1 sunrise: 06:03:19 sunset: 18:10:54 2013 3 21 Greenwich 51 28 N 0 0 E -0.583 0 sunrise: 06:01:18 sunset: 18:12:56 2013 3 21 Greenwich 51 28 N 0 0 E -0.583 1 sunrise: 05:59:35 sunset: 18:14:39 2013 3 21 Greenwich 51 28 N 0 0 E -0.833 0 sunrise: 05:59:42 sunset: 18:14:32 2013 3 21 Greenwich 51 28 N 0 0 E -0.833 1 sunrise: 05:57:58 sunset: 18:16:15 2013 3 21 Greenwich 51 28 N 0 0 E -12 0 sunrise: 04:46:55 sunset: 19:27:18 2013 3 21 Greenwich 51 28 N 0 0 E -12 1 sunrise: 04:45:08 sunset: 19:29:06 2013 3 21 Greenwich 51 28 N 0 0 E -18 0 sunrise: 04:05:46 sunset: 20:08:28 2013 3 21 Greenwich 51 28 N 0 0 E -18 1 sunrise: 04:03:52 sunset: 20:10:22 2013 3 21 Reykjavik 64 4 N 21 58 W 10 0 sunrise: 09:04:39 sunset: 18:05:17 2013 3 21 Reykjavik 64 4 N 21 58 W 10 1 sunrise: 09:02:03 sunset: 18:07:53 2013 3 21 Reykjavik 64 4 N 21 58 W 0 0 sunrise: 07:31:22 sunset: 19:38:33 2013 3 21 Reykjavik 64 4 N 21 58 W 0 1 sunrise: 07:28:55 sunset: 19:41:00 2013 3 21 Reykjavik 64 4 N 21 58 W -0.583 0 sunrise: 07:26:02 sunset: 19:43:54 2013 3 21 Reykjavik 64 4 N 21 58 W -0.583 1 sunrise: 07:23:35 sunset: 19:46:21 2013 3 21 Reykjavik 64 4 N 21 58 W -0.833 0 sunrise: 07:23:45 sunset: 19:46:11 2013 3 21 Reykjavik 64 4 N 21 58 W -0.833 1 sunrise: 07:21:18 sunset: 19:48:38 2013 3 21 Reykjavik 64 4 N 21 58 W -12 0 sunrise: 05:37:19 sunset: 21:32:37 2013 3 21 Reykjavik 64 4 N 21 58 W -12 1 sunrise: 05:34:33 sunset: 21:35:23 2013 3 21 Reykjavik 64 4 N 21 58 W -18 0 sunrise: 04:29:59 sunset: 22:39:57 2013 3 21 Reykjavik 64 4 N 21 58 W -18 1 sunrise: 04:26:35 sunset: 22:43:20 2013 3 21 Quito 0 15 S 78 35 W 10 0 sunrise: 12:01:24 sunset: 22:41:22 2013 3 21 Quito 0 15 S 78 35 W 10 1 sunrise: 12:00:19 sunset: 22:42:26 2013 3 21 Quito 0 15 S 78 35 W 0 0 sunrise: 11:21:23 sunset: 23:21:22 2013 3 21 Quito 0 15 S 78 35 W 0 1 sunrise: 11:20:19 sunset: 23:22:27 2013 3 21 Quito 0 15 S 78 35 W -0.583 0 sunrise: 11:19:04 sunset: 23:23:42 2013 3 21 Quito 0 15 S 78 35 W -0.583 1 sunrise: 11:17:59 sunset: 23:24:47 2013 3 21 Quito 0 15 S 78 35 W -0.833 0 sunrise: 11:18:04 sunset: 23:24:42 2013 3 21 Quito 0 15 S 78 35 W -0.833 1 sunrise: 11:16:59 sunset: 23:25:47 2013 3 21 Quito 0 15 S 78 35 W -12 0 sunrise: 10:33:23 sunset: 24:09:23 2013 3 21 Quito 0 15 S 78 35 W -12 1 sunrise: 10:32:19 sunset: 24:10:27 2013 3 21 Quito 0 15 S 78 35 W -18 0 sunrise: 10:09:23 sunset: 24:33:23 2013 3 21 Quito 0 15 S 78 35 W -18 1 sunrise: 10:08:19 sunset: 24:34:27 2013 3 21 El_Hierro 27 44 N 18 3 W 10 0 sunrise: 08:03:38 sunset: 18:34:58 2013 3 21 El_Hierro 27 44 N 18 3 W 10 1 sunrise: 08:02:25 sunset: 18:36:11 2013 3 21 El_Hierro 27 44 N 18 3 W 0 0 sunrise: 07:18:23 sunset: 19:20:13 2013 3 21 El_Hierro 27 44 N 18 3 W 0 1 sunrise: 07:17:11 sunset: 19:21:25 2013 3 21 El_Hierro 27 44 N 18 3 W -0.583 0 sunrise: 07:15:45 sunset: 19:22:51 2013 3 21 El_Hierro 27 44 N 18 3 W -0.583 1 sunrise: 07:14:33 sunset: 19:24:03 2013 3 21 El_Hierro 27 44 N 18 3 W -0.833 0 sunrise: 07:14:38 sunset: 19:23:58 2013 3 21 El_Hierro 27 44 N 18 3 W -0.833 1 sunrise: 07:13:25 sunset: 19:25:11 2013 3 21 El_Hierro 27 44 N 18 3 W -12 0 sunrise: 06:24:01 sunset: 20:14:35 2013 3 21 El_Hierro 27 44 N 18 3 W -12 1 sunrise: 06:22:48 sunset: 20:15:48 2013 3 21 El_Hierro 27 44 N 18 3 W -18 0 sunrise: 05:56:35 sunset: 20:42:01 2013 3 21 El_Hierro 27 44 N 18 3 W -18 1 sunrise: 05:55:22 sunset: 20:43:14 2013 6 21 Greenwich 51 28 N 0 0 E 10 0 sunrise: 05:06:09 sunset: 18:57:30 2013 6 21 Greenwich 51 28 N 0 0 E 10 1 sunrise: 05:04:17 sunset: 18:59:22 2013 6 21 Greenwich 51 28 N 0 0 E 0 0 sunrise: 03:49:54 sunset: 20:13:45 2013 6 21 Greenwich 51 28 N 0 0 E 0 1 sunrise: 03:47:42 sunset: 20:15:56 2013 6 21 Greenwich 51 28 N 0 0 E -0.583 0 sunrise: 03:45:00 sunset: 20:18:39 2013 6 21 Greenwich 51 28 N 0 0 E -0.583 1 sunrise: 03:42:47 sunset: 20:20:52 2013 6 21 Greenwich 51 28 N 0 0 E -0.833 0 sunrise: 03:42:53 sunset: 20:20:46 2013 6 21 Greenwich 51 28 N 0 0 E -0.833 1 sunrise: 03:40:38 sunset: 20:23:00 2013 6 21 Greenwich 51 28 N 0 0 E -12 0 sunrise: 01:40:50 sunset: 22:22:48 2013 6 21 Greenwich 51 28 N 0 0 E -12 1 sunrise: 01:36:28 sunset: 22:27:11 2013 6 21 Greenwich 51 28 N 0 0 E -18 0 sunrise: 00:01:49 sunset: 24:01:49 polar night or midnight sun 2013 6 21 Greenwich 51 28 N 0 0 E -18 1 sunrise: 00:01:49 sunset: 24:01:49 polar night or midnight sun 2013 6 21 Reykjavik 64 4 N 21 58 W 10 0 sunrise: 05:40:30 sunset: 21:18:55 2013 6 21 Reykjavik 64 4 N 21 58 W 10 1 sunrise: 05:37:35 sunset: 21:21:49 2013 6 21 Reykjavik 64 4 N 21 58 W 0 0 sunrise: 03:17:28 sunset: 23:41:56 2013 6 21 Reykjavik 64 4 N 21 58 W 0 1 sunrise: 03:11:33 sunset: 23:47:52 2013 6 21 Reykjavik 64 4 N 21 58 W -0.583 0 sunrise: 03:03:50 sunset: 23:55:34 2013 6 21 Reykjavik 64 4 N 21 58 W -0.583 1 sunrise: 02:57:03 sunset: 24:02:21 2013 6 21 Reykjavik 64 4 N 21 58 W -0.833 0 sunrise: 02:57:23 sunset: 24:02:01 2013 6 21 Reykjavik 64 4 N 21 58 W -0.833 1 sunrise: 02:50:06 sunset: 24:09:19 2013 6 21 Reykjavik 64 4 N 21 58 W -12 0 sunrise: 01:29:42 sunset: 25:29:42 polar night or midnight sun 2013 6 21 Reykjavik 64 4 N 21 58 W -12 1 sunrise: 01:29:42 sunset: 25:29:42 polar night or midnight sun 2013 6 21 Reykjavik 64 4 N 21 58 W -18 0 sunrise: 01:29:42 sunset: 25:29:42 polar night or midnight sun 2013 6 21 Reykjavik 64 4 N 21 58 W -18 1 sunrise: 01:29:42 sunset: 25:29:42 polar night or midnight sun 2013 6 21 Quito 0 15 S 78 35 W 10 0 sunrise: 12:00:17 sunset: 22:32:07 2013 6 21 Quito 0 15 S 78 35 W 10 1 sunrise: 11:59:08 sunset: 22:33:16 2013 6 21 Quito 0 15 S 78 35 W 0 0 sunrise: 11:16:38 sunset: 23:15:46 2013 6 21 Quito 0 15 S 78 35 W 0 1 sunrise: 11:15:29 sunset: 23:16:55 2013 6 21 Quito 0 15 S 78 35 W -0.583 0 sunrise: 11:14:06 sunset: 23:18:19 2013 6 21 Quito 0 15 S 78 35 W -0.583 1 sunrise: 11:12:57 sunset: 23:19:27 2013 6 21 Quito 0 15 S 78 35 W -0.833 0 sunrise: 11:13:00 sunset: 23:19:24 2013 6 21 Quito 0 15 S 78 35 W -0.833 1 sunrise: 11:11:52 sunset: 23:20:33 2013 6 21 Quito 0 15 S 78 35 W -12 0 sunrise: 10:24:15 sunset: 24:08:09 2013 6 21 Quito 0 15 S 78 35 W -12 1 sunrise: 10:23:07 sunset: 24:09:18 2013 6 21 Quito 0 15 S 78 35 W -18 0 sunrise: 09:57:56 sunset: 24:34:28 2013 6 21 Quito 0 15 S 78 35 W -18 1 sunrise: 09:56:47 sunset: 24:35:38 2013 6 21 El_Hierro 27 44 N 18 3 W 10 0 sunrise: 07:10:48 sunset: 19:17:16 2013 6 21 El_Hierro 27 44 N 18 3 W 10 1 sunrise: 07:09:32 sunset: 19:18:32 2013 6 21 El_Hierro 27 44 N 18 3 W 0 0 sunrise: 06:21:20 sunset: 20:06:44 2013 6 21 El_Hierro 27 44 N 18 3 W 0 1 sunrise: 06:20:00 sunset: 20:08:04 2013 6 21 El_Hierro 27 44 N 18 3 W -0.583 0 sunrise: 06:18:23 sunset: 20:09:41 2013 6 21 El_Hierro 27 44 N 18 3 W -0.583 1 sunrise: 06:17:03 sunset: 20:11:01 2013 6 21 El_Hierro 27 44 N 18 3 W -0.833 0 sunrise: 06:17:07 sunset: 20:10:57 2013 6 21 El_Hierro 27 44 N 18 3 W -0.833 1 sunrise: 06:15:47 sunset: 20:12:17 2013 6 21 El_Hierro 27 44 N 18 3 W -12 0 sunrise: 05:18:16 sunset: 21:09:48 2013 6 21 El_Hierro 27 44 N 18 3 W -12 1 sunrise: 05:16:49 sunset: 21:11:15 2013 6 21 El_Hierro 27 44 N 18 3 W -18 0 sunrise: 04:44:08 sunset: 21:43:56 2013 6 21 El_Hierro 27 44 N 18 3 W -18 1 sunrise: 04:42:35 sunset: 21:45:29 2013 8 31 Greenwich 51 28 N 0 0 E 10 0 sunrise: 06:21:59 sunset: 17:38:31 2013 8 31 Greenwich 51 28 N 0 0 E 10 1 sunrise: 06:20:18 sunset: 17:40:12 2013 8 31 Greenwich 51 28 N 0 0 E 0 0 sunrise: 05:17:07 sunset: 18:43:23 2013 8 31 Greenwich 51 28 N 0 0 E 0 1 sunrise: 05:15:22 sunset: 18:45:08 2013 8 31 Greenwich 51 28 N 0 0 E -0.583 0 sunrise: 05:13:15 sunset: 18:47:15 2013 8 31 Greenwich 51 28 N 0 0 E -0.583 1 sunrise: 05:11:30 sunset: 18:49:00 2013 8 31 Greenwich 51 28 N 0 0 E -0.833 0 sunrise: 05:11:36 sunset: 18:48:54 2013 8 31 Greenwich 51 28 N 0 0 E -0.833 1 sunrise: 05:09:50 sunset: 18:50:40 2013 8 31 Greenwich 51 28 N 0 0 E -12 0 sunrise: 03:53:42 sunset: 20:06:48 2013 8 31 Greenwich 51 28 N 0 0 E -12 1 sunrise: 03:51:44 sunset: 20:08:46 2013 8 31 Greenwich 51 28 N 0 0 E -18 0 sunrise: 03:06:10 sunset: 20:54:20 2013 8 31 Greenwich 51 28 N 0 0 E -18 1 sunrise: 03:03:54 sunset: 20:56:36 2013 8 31 Reykjavik 64 4 N 21 58 W 10 0 sunrise: 07:50:06 sunset: 19:06:06 2013 8 31 Reykjavik 64 4 N 21 58 W 10 1 sunrise: 07:47:41 sunset: 19:08:31 2013 8 31 Reykjavik 64 4 N 21 58 W 0 0 sunrise: 06:16:55 sunset: 20:39:17 2013 8 31 Reykjavik 64 4 N 21 58 W 0 1 sunrise: 06:14:21 sunset: 20:41:51 2013 8 31 Reykjavik 64 4 N 21 58 W -0.583 0 sunrise: 06:11:14 sunset: 20:44:58 2013 8 31 Reykjavik 64 4 N 21 58 W -0.583 1 sunrise: 06:08:39 sunset: 20:47:33 2013 8 31 Reykjavik 64 4 N 21 58 W -0.833 0 sunrise: 06:08:47 sunset: 20:47:25 2013 8 31 Reykjavik 64 4 N 21 58 W -0.833 1 sunrise: 06:06:11 sunset: 20:50:01 2013 8 31 Reykjavik 64 4 N 21 58 W -12 0 sunrise: 04:00:45 sunset: 22:55:27 2013 8 31 Reykjavik 64 4 N 21 58 W -12 1 sunrise: 03:56:51 sunset: 22:59:21 2013 8 31 Reykjavik 64 4 N 21 58 W -18 0 sunrise: 01:28:06 sunset: 25:28:06 polar night or midnight sun 2013 8 31 Reykjavik 64 4 N 21 58 W -18 1 sunrise: 01:28:06 sunset: 25:28:06 polar night or midnight sun 2013 8 31 Quito 0 15 S 78 35 W 10 0 sunrise: 11:55:06 sunset: 22:33:55 2013 8 31 Quito 0 15 S 78 35 W 10 1 sunrise: 11:54:02 sunset: 22:35:00 2013 8 31 Quito 0 15 S 78 35 W 0 0 sunrise: 11:14:40 sunset: 23:14:22 2013 8 31 Quito 0 15 S 78 35 W 0 1 sunrise: 11:13:36 sunset: 23:15:26 2013 8 31 Quito 0 15 S 78 35 W -0.583 0 sunrise: 11:12:18 sunset: 23:16:43 2013 8 31 Quito 0 15 S 78 35 W -0.583 1 sunrise: 11:11:14 sunset: 23:17:47 2013 8 31 Quito 0 15 S 78 35 W -0.833 0 sunrise: 11:11:18 sunset: 23:17:44 2013 8 31 Quito 0 15 S 78 35 W -0.833 1 sunrise: 11:10:13 sunset: 23:18:48 2013 8 31 Quito 0 15 S 78 35 W -12 0 sunrise: 10:26:08 sunset: 24:02:53 2013 8 31 Quito 0 15 S 78 35 W -12 1 sunrise: 10:25:04 sunset: 24:03:58 2013 8 31 Quito 0 15 S 78 35 W -18 0 sunrise: 10:01:52 sunset: 24:27:10 2013 8 31 Quito 0 15 S 78 35 W -18 1 sunrise: 10:00:47 sunset: 24:28:14 2013 8 31 El_Hierro 27 44 N 18 3 W 10 0 sunrise: 07:40:03 sunset: 18:44:50 2013 8 31 El_Hierro 27 44 N 18 3 W 10 1 sunrise: 07:38:51 sunset: 18:46:01 2013 8 31 El_Hierro 27 44 N 18 3 W 0 0 sunrise: 06:54:30 sunset: 19:30:22 2013 8 31 El_Hierro 27 44 N 18 3 W 0 1 sunrise: 06:53:17 sunset: 19:31:35 2013 8 31 El_Hierro 27 44 N 18 3 W -0.583 0 sunrise: 06:51:50 sunset: 19:33:02 2013 8 31 El_Hierro 27 44 N 18 3 W -0.583 1 sunrise: 06:50:37 sunset: 19:34:15 2013 8 31 El_Hierro 27 44 N 18 3 W -0.833 0 sunrise: 06:50:41 sunset: 19:34:11 2013 8 31 El_Hierro 27 44 N 18 3 W -0.833 1 sunrise: 06:49:28 sunset: 19:35:24 2013 8 31 El_Hierro 27 44 N 18 3 W -12 0 sunrise: 05:58:50 sunset: 20:26:02 2013 8 31 El_Hierro 27 44 N 18 3 W -12 1 sunrise: 05:57:35 sunset: 20:27:17 2013 8 31 El_Hierro 27 44 N 18 3 W -18 0 sunrise: 05:30:17 sunset: 20:54:35 2013 8 31 El_Hierro 27 44 N 18 3 W -18 1 sunrise: 05:29:00 sunset: 20:55:52 2013 9 21 Greenwich 51 28 N 0 0 E 10 0 sunrise: 06:54:59 sunset: 16:51:01 2013 9 21 Greenwich 51 28 N 0 0 E 10 1 sunrise: 06:53:14 sunset: 16:52:45 2013 9 21 Greenwich 51 28 N 0 0 E 0 0 sunrise: 05:50:20 sunset: 17:55:39 2013 9 21 Greenwich 51 28 N 0 0 E 0 1 sunrise: 05:48:38 sunset: 17:57:21 2013 9 21 Greenwich 51 28 N 0 0 E -0.583 0 sunrise: 05:46:36 sunset: 17:59:24 2013 9 21 Greenwich 51 28 N 0 0 E -0.583 1 sunrise: 05:44:53 sunset: 18:01:06 2013 9 21 Greenwich 51 28 N 0 0 E -0.833 0 sunrise: 05:44:59 sunset: 18:01:00 2013 9 21 Greenwich 51 28 N 0 0 E -0.833 1 sunrise: 05:43:17 sunset: 18:02:42 2013 9 21 Greenwich 51 28 N 0 0 E -12 0 sunrise: 04:32:11 sunset: 19:13:48 2013 9 21 Greenwich 51 28 N 0 0 E -12 1 sunrise: 04:30:24 sunset: 19:15:35 2013 9 21 Greenwich 51 28 N 0 0 E -18 0 sunrise: 03:50:58 sunset: 19:55:01 2013 9 21 Greenwich 51 28 N 0 0 E -18 1 sunrise: 03:49:05 sunset: 19:56:54 2013 9 21 Reykjavik 64 4 N 21 58 W 10 0 sunrise: 08:49:55 sunset: 17:51:46 2013 9 21 Reykjavik 64 4 N 21 58 W 10 1 sunrise: 08:47:21 sunset: 17:54:20 2013 9 21 Reykjavik 64 4 N 21 58 W 0 0 sunrise: 07:16:41 sunset: 19:25:00 2013 9 21 Reykjavik 64 4 N 21 58 W 0 1 sunrise: 07:14:16 sunset: 19:27:25 2013 9 21 Reykjavik 64 4 N 21 58 W -0.583 0 sunrise: 07:11:21 sunset: 19:30:20 2013 9 21 Reykjavik 64 4 N 21 58 W -0.583 1 sunrise: 07:08:55 sunset: 19:32:46 2013 9 21 Reykjavik 64 4 N 21 58 W -0.833 0 sunrise: 07:09:04 sunset: 19:32:37 2013 9 21 Reykjavik 64 4 N 21 58 W -0.833 1 sunrise: 07:06:38 sunset: 19:35:03 2013 9 21 Reykjavik 64 4 N 21 58 W -12 0 sunrise: 05:22:33 sunset: 21:19:08 2013 9 21 Reykjavik 64 4 N 21 58 W -12 1 sunrise: 05:19:48 sunset: 21:21:53 2013 9 21 Reykjavik 64 4 N 21 58 W -18 0 sunrise: 04:15:03 sunset: 22:26:38 2013 9 21 Reykjavik 64 4 N 21 58 W -18 1 sunrise: 04:11:40 sunset: 22:30:01 2013 9 21 Quito 0 15 S 78 35 W 10 0 sunrise: 11:47:16 sunset: 22:27:14 2013 9 21 Quito 0 15 S 78 35 W 10 1 sunrise: 11:46:12 sunset: 22:28:18 2013 9 21 Quito 0 15 S 78 35 W 0 0 sunrise: 11:07:15 sunset: 23:07:14 2013 9 21 Quito 0 15 S 78 35 W 0 1 sunrise: 11:06:12 sunset: 23:08:18 2013 9 21 Quito 0 15 S 78 35 W -0.583 0 sunrise: 11:04:55 sunset: 23:09:34 2013 9 21 Quito 0 15 S 78 35 W -0.583 1 sunrise: 11:03:52 sunset: 23:10:38 2013 9 21 Quito 0 15 S 78 35 W -0.833 0 sunrise: 11:03:55 sunset: 23:10:34 2013 9 21 Quito 0 15 S 78 35 W -0.833 1 sunrise: 11:02:52 sunset: 23:11:38 2013 9 21 Quito 0 15 S 78 35 W -12 0 sunrise: 10:19:15 sunset: 23:55:15 2013 9 21 Quito 0 15 S 78 35 W -12 1 sunrise: 10:18:12 sunset: 23:56:18 2013 9 21 Quito 0 15 S 78 35 W -18 0 sunrise: 09:55:15 sunset: 24:19:15 2013 9 21 Quito 0 15 S 78 35 W -18 1 sunrise: 09:54:12 sunset: 24:20:18 2013 9 21 El_Hierro 27 44 N 18 3 W 10 0 sunrise: 07:49:21 sunset: 18:21:01 2013 9 21 El_Hierro 27 44 N 18 3 W 10 1 sunrise: 07:48:08 sunset: 18:22:13 2013 9 21 El_Hierro 27 44 N 18 3 W 0 0 sunrise: 07:04:06 sunset: 19:06:15 2013 9 21 El_Hierro 27 44 N 18 3 W 0 1 sunrise: 07:02:54 sunset: 19:07:27 2013 9 21 El_Hierro 27 44 N 18 3 W -0.583 0 sunrise: 07:01:28 sunset: 19:08:53 2013 9 21 El_Hierro 27 44 N 18 3 W -0.583 1 sunrise: 07:00:16 sunset: 19:10:05 2013 9 21 El_Hierro 27 44 N 18 3 W -0.833 0 sunrise: 07:00:20 sunset: 19:10:01 2013 9 21 El_Hierro 27 44 N 18 3 W -0.833 1 sunrise: 06:59:08 sunset: 19:11:13 2013 9 21 El_Hierro 27 44 N 18 3 W -12 0 sunrise: 06:09:44 sunset: 20:00:37 2013 9 21 El_Hierro 27 44 N 18 3 W -12 1 sunrise: 06:08:31 sunset: 20:01:50 2013 9 21 El_Hierro 27 44 N 18 3 W -18 0 sunrise: 05:42:18 sunset: 20:28:03 2013 9 21 El_Hierro 27 44 N 18 3 W -18 1 sunrise: 05:41:04 sunset: 20:29:17 2013 12 31 Greenwich 51 28 N 0 0 E 10 0 sunrise: 09:50:37 sunset: 14:15:32 2013 12 31 Greenwich 51 28 N 0 0 E 10 1 sunrise: 09:47:15 sunset: 14:18:54 2013 12 31 Greenwich 51 28 N 0 0 E 0 0 sunrise: 08:12:21 sunset: 15:53:48 2013 12 31 Greenwich 51 28 N 0 0 E 0 1 sunrise: 08:10:07 sunset: 15:56:02 2013 12 31 Greenwich 51 28 N 0 0 E -0.583 0 sunrise: 08:07:34 sunset: 15:58:35 2013 12 31 Greenwich 51 28 N 0 0 E -0.583 1 sunrise: 08:05:22 sunset: 16:00:47 2013 12 31 Greenwich 51 28 N 0 0 E -0.833 0 sunrise: 08:05:32 sunset: 16:00:37 2013 12 31 Greenwich 51 28 N 0 0 E -0.833 1 sunrise: 08:03:20 sunset: 16:02:49 2013 12 31 Greenwich 51 28 N 0 0 E -12 0 sunrise: 06:42:40 sunset: 17:23:29 2013 12 31 Greenwich 51 28 N 0 0 E -12 1 sunrise: 06:40:47 sunset: 17:25:22 2013 12 31 Greenwich 51 28 N 0 0 E -18 0 sunrise: 06:02:03 sunset: 18:04:06 2013 12 31 Greenwich 51 28 N 0 0 E -18 1 sunrise: 06:00:15 sunset: 18:05:54 2013 12 31 Reykjavik 64 4 N 21 58 W 10 0 sunrise: 13:30:58 sunset: 13:30:58 polar night or midnight sun 2013 12 31 Reykjavik 64 4 N 21 58 W 10 1 sunrise: 13:30:58 sunset: 13:30:58 polar night or midnight sun 2013 12 31 Reykjavik 64 4 N 21 58 W 0 0 sunrise: 11:35:19 sunset: 15:26:38 2013 12 31 Reykjavik 64 4 N 21 58 W 0 1 sunrise: 11:29:51 sunset: 15:32:05 2013 12 31 Reykjavik 64 4 N 21 58 W -0.583 0 sunrise: 11:23:51 sunset: 15:38:06 2013 12 31 Reykjavik 64 4 N 21 58 W -0.583 1 sunrise: 11:18:49 sunset: 15:43:08 2013 12 31 Reykjavik 64 4 N 21 58 W -0.833 0 sunrise: 11:19:12 sunset: 15:42:45 2013 12 31 Reykjavik 64 4 N 21 58 W -0.833 1 sunrise: 11:14:19 sunset: 15:47:37 2013 12 31 Reykjavik 64 4 N 21 58 W -12 0 sunrise: 08:55:02 sunset: 18:06:54 2013 12 31 Reykjavik 64 4 N 21 58 W -12 1 sunrise: 08:52:13 sunset: 18:09:43 2013 12 31 Reykjavik 64 4 N 21 58 W -18 0 sunrise: 07:55:38 sunset: 19:06:19 2013 12 31 Reykjavik 64 4 N 21 58 W -18 1 sunrise: 07:53:03 sunset: 19:08:53 2013 12 31 Quito 0 15 S 78 35 W 10 0 sunrise: 12:00:35 sunset: 22:34:26 2013 12 31 Quito 0 15 S 78 35 W 10 1 sunrise: 11:59:24 sunset: 22:35:37 2013 12 31 Quito 0 15 S 78 35 W 0 0 sunrise: 11:17:05 sunset: 23:17:56 2013 12 31 Quito 0 15 S 78 35 W 0 1 sunrise: 11:15:54 sunset: 23:19:07 2013 12 31 Quito 0 15 S 78 35 W -0.583 0 sunrise: 11:14:33 sunset: 23:20:28 2013 12 31 Quito 0 15 S 78 35 W -0.583 1 sunrise: 11:13:22 sunset: 23:21:39 2013 12 31 Quito 0 15 S 78 35 W -0.833 0 sunrise: 11:13:28 sunset: 23:21:33 2013 12 31 Quito 0 15 S 78 35 W -0.833 1 sunrise: 11:12:17 sunset: 23:22:44 2013 12 31 Quito 0 15 S 78 35 W -12 0 sunrise: 10:24:50 sunset: 24:10:11 2013 12 31 Quito 0 15 S 78 35 W -12 1 sunrise: 10:23:39 sunset: 24:11:22 2013 12 31 Quito 0 15 S 78 35 W -18 0 sunrise: 09:58:34 sunset: 24:36:27 2013 12 31 Quito 0 15 S 78 35 W -18 1 sunrise: 09:57:23 sunset: 24:37:39 2013 12 31 El_Hierro 27 44 N 18 3 W 10 0 sunrise: 08:58:57 sunset: 17:31:39 2013 12 31 El_Hierro 27 44 N 18 3 W 10 1 sunrise: 08:57:30 sunset: 17:33:06 2013 12 31 El_Hierro 27 44 N 18 3 W 0 0 sunrise: 08:07:02 sunset: 18:23:34 2013 12 31 El_Hierro 27 44 N 18 3 W 0 1 sunrise: 08:05:40 sunset: 18:24:56 2013 12 31 El_Hierro 27 44 N 18 3 W -0.583 0 sunrise: 08:04:06 sunset: 18:26:30 2013 12 31 El_Hierro 27 44 N 18 3 W -0.583 1 sunrise: 08:02:44 sunset: 18:27:52 2013 12 31 El_Hierro 27 44 N 18 3 W -0.833 0 sunrise: 08:02:50 sunset: 18:27:45 2013 12 31 El_Hierro 27 44 N 18 3 W -0.833 1 sunrise: 08:01:29 sunset: 18:29:07 2013 12 31 El_Hierro 27 44 N 18 3 W -12 0 sunrise: 07:08:05 sunset: 19:22:31 2013 12 31 El_Hierro 27 44 N 18 3 W -12 1 sunrise: 07:06:47 sunset: 19:23:49 2013 12 31 El_Hierro 27 44 N 18 3 W -18 0 sunrise: 06:39:29 sunset: 19:51:07 2013 12 31 El_Hierro 27 44 N 18 3 W -18 1 sunrise: 06:38:12 sunset: 19:52:24 DATA } DateTime-Event-Sunrise-0.0505/lib/0000755000175000017500000000000012631373464014343 5ustar jfjfDateTime-Event-Sunrise-0.0505/lib/DateTime/0000755000175000017500000000000012631373464016037 5ustar jfjfDateTime-Event-Sunrise-0.0505/lib/DateTime/Event/0000755000175000017500000000000012631373464017120 5ustar jfjfDateTime-Event-Sunrise-0.0505/lib/DateTime/Event/Sunrise.pm0000644000175000017500000011516412631367110021105 0ustar jfjf# -*- encoding: utf-8; indent-tabs-mode: nil -*- # # Perl DateTime extension for computing the sunrise/sunset on a given day # Copyright (C) 1999-2004, 2013-2014 Ron Hill and Jean Forget # # See the license in the embedded documentation below. # package DateTime::Event::Sunrise; use strict; use warnings; require Exporter; use POSIX qw(floor); use Math::Trig; use Carp; use DateTime; use DateTime::Set; use Params::Validate qw(:all); use Set::Infinite qw(inf $inf); use vars qw( $VERSION $RADEG $DEGRAD @ISA ); @ISA = qw( Exporter ); $VERSION = '0.0505'; $RADEG = ( 180 / pi ); $DEGRAD = ( pi / 180 ); my $INV360 = ( 1.0 / 360.0 ); # Julian day number for the 0th January 2000 (that is, 31st December 1999) my $jd_2000_Jan_0 = DateTime->new(year => 1999, month => 12, day => 31, time_zone => 'UTC')->jd; sub new { my $class = shift; if (@_ % 2 != 0) { croak "Odd number of parameters"; } my %args = @_; if (exists $args{iteration} && exists $args{precise}) { croak "Parameter 'iteration' is deprecated, use only 'precise'"; } %args = validate( @_, { longitude => { type => SCALAR, optional => 1, default => 0 }, latitude => { type => SCALAR, optional => 1, default => 0 }, altitude => { type => SCALAR, default => '-0.833', regex => qr/^(-?\d+(?:\.\d+)?)$/ }, iteration => { type => SCALAR, default => '0' }, precise => { type => SCALAR, default => '0' }, upper_limb => { type => SCALAR, default => '0' }, silent => { type => SCALAR, default => '0' }, } ); # Making old and new parameters synonymous unless (exists $args{precise}) { $args{precise} = $args{iteration}; } # TODO : get rid of the old parameters after this point $args{iteration} = $args{precise}; return bless \%args, $class; } # # # FUNCTIONAL SEQUENCE for sunrise # # _GIVEN # A sunrise object that was created by the new method # # _THEN # # setup subs for following/previous sunrise times # # # _RETURN # # A new DateTime::Set recurrence object # sub sunrise { my $class = shift; my $self = $class->new(@_); return DateTime::Set->from_recurrence( next => sub { return $_[0] if $_[0]->is_infinite; $self->_following_sunrise( $_[0] ); }, previous => sub { return $_[0] if $_[0]->is_infinite; $self->_previous_sunrise( $_[0] ); } ); } # # # FUNCTIONAL SEQUENCE for sunset # # _GIVEN # # A sunrise object that was created by the new method # _THEN # # Setup subs for following/previous sunset times # # # _RETURN # # A new DateTime::Set recurrence object # sub sunset { my $class = shift; my $self = $class->new(@_); return DateTime::Set->from_recurrence( next => sub { return $_[0] if $_[0]->is_infinite; $self->_following_sunset( $_[0] ); }, previous => sub { return $_[0] if $_[0]->is_infinite; $self->_previous_sunset( $_[0] ); } ); } # # # FUNCTIONAL SEQUENCE for sunset_datetime # # _GIVEN # # A sunrise object # A DateTime object # # _THEN # # Validate the DateTime object is valid # Compute sunrise and sunset # # # _RETURN # # DateTime object that contains the sunset time # sub sunset_datetime { my $self = shift; my $dt = shift; my $class = ref($dt); if ( ! $dt->isa('DateTime') ) { croak("Dates need to be DateTime objects"); } my ( undef, $tmp_set ) = _sunrise( $self, $dt ); return $tmp_set; } # # # FUNCTIONAL SEQUENCE for sunrise_datetime # # _GIVEN # # A sunrise object # A DateTime object # # _THEN # # Validate the DateTime object is valid # Compute sunrise and sunset # # # _RETURN # # DateTime object that contains the sunrise times # sub sunrise_datetime { my $self = shift; my $dt = shift; my $class = ref($dt); if ( ! $dt->isa('DateTime') ) { croak("Dates need to be DateTime objects"); } my ( $tmp_rise, undef ) = _sunrise( $self, $dt ); return $tmp_rise; } # # # FUNCTIONAL SEQUENCE for sunrise_sunset_span # # _GIVEN # # A sunrise object # A DateTime object # # _THEN # # Validate the DateTime object is valid # Compute sunrise and sunset # # # _RETURN # # DateTime Span object that contains the sunrise/sunset times # sub sunrise_sunset_span { my $self = shift; my $dt = shift; my $class = ref($dt); if ( ! $dt->isa('DateTime') ) { croak("Dates need to be DateTime objects"); } my ( $tmp_rise, $tmp_set ) = _sunrise( $self, $dt ); return DateTime::Span->from_datetimes( start => $tmp_rise, end => $tmp_set ); } # # FUNCTIONAL SEQUENCE for is_polar_night # # _GIVEN # # A sunrise object # A DateTime object # # _THEN # # Validate the DateTime object is valid # Compute sunrise and sunset # # _RETURN # # A boolean flag telling whether the sun will stay under the horizon or not # sub is_polar_night { my $self = shift; my $dt = shift; my $class = ref($dt); if ( ! $dt->isa('DateTime') ) { croak("Dates need to be DateTime objects"); } my ( undef, undef, $rise_season, $set_season ) = _sunrise( $self, $dt, 1 ); return ($rise_season < 0 || $set_season < 0); } # # FUNCTIONAL SEQUENCE for is_polar_day # # _GIVEN # # A sunrise object # A DateTime object # # _THEN # # Validate the DateTime object is valid # Compute sunrise and sunset # # _RETURN # # A boolean flag telling whether the sun will stay above the horizon or not # sub is_polar_day { my $self = shift; my $dt = shift; my $class = ref($dt); if ( ! $dt->isa('DateTime') ) { croak("Dates need to be DateTime objects"); } my ( undef, undef, $rise_season, $set_season ) = _sunrise( $self, $dt, 1 ); return ($rise_season > 0 || $set_season > 0); } # # FUNCTIONAL SEQUENCE for is_day_and_night # # _GIVEN # # A sunrise object # A DateTime object # # _THEN # # Validate the DateTime object is valid # Compute sunrise and sunset # # _RETURN # # A boolean flag telling whether the sun will rise and set or not # sub is_day_and_night { my $self = shift; my $dt = shift; my $class = ref($dt); if ( ! $dt->isa('DateTime') ) { croak("Dates need to be DateTime objects"); } my ( undef, undef, $rise_season, $set_season ) = _sunrise( $self, $dt, 1 ); return ($rise_season == 0 && $set_season == 0); } # # # FUNCTIONAL SEQUENCE for _following_sunrise # # _GIVEN # # A sunrise object # A DateTime object # # _THEN # # Validate the DateTime object is valid # Compute sunrise and return if it is greater # than the original if not add one day and recompute # # # _RETURN # # A new DateTime object that contains the sunrise time # sub _following_sunrise { my $self = shift; my $dt = shift; croak( "Dates need to be DateTime objects (" . ref($dt) . ")" ) unless ( $dt->isa('DateTime') ); my ( $tmp_rise, undef ) = _sunrise( $self, $dt ); return $tmp_rise if $tmp_rise > $dt; my $d = DateTime::Duration->new( days => 1, ); my $new_dt = $dt + $d; ( $tmp_rise, undef ) = _sunrise( $self, $new_dt ); return $tmp_rise if $tmp_rise > $dt; $new_dt = $new_dt + $d; ( $tmp_rise, undef ) = _sunrise( $self, $new_dt ); return $tmp_rise; } # # # FUNCTIONAL SEQUENCE for _previous_sunrise # # _GIVEN # A sunrise object # A DateTime object # # _THEN # # Validate the DateTime Object # Compute sunrise and return if it is less than # the original object if not subtract one day and recompute # # _RETURN # # A new DateTime Object that contains the sunrise time # sub _previous_sunrise { my $self = shift; my $dt = shift; croak( "Dates need to be DateTime objects (" . ref($dt) . ")" ) unless ( $dt->isa('DateTime') ); my ( $tmp_rise, undef ) = _sunrise( $self, $dt ); return $tmp_rise if $tmp_rise < $dt; my $d = DateTime::Duration->new( days => 1, ); my $new_dt = $dt - $d; ( $tmp_rise, undef ) = _sunrise( $self, $new_dt ); return $tmp_rise if $tmp_rise < $dt; $new_dt = $new_dt - $d; ( $tmp_rise, undef ) = _sunrise( $self, $new_dt ); return $tmp_rise; } # # # FUNCTIONAL SEQUENCE for _following_sunset # # _GIVEN # A sunrise object # A DateTime object # # _THEN # # Validate the DateTime object is valid # Compute sunset and return if it is greater # than the original if not add one day and recompute # # _RETURN # # A DateTime object with sunset time # sub _following_sunset { my $self = shift; my $dt = shift; croak( "Dates need to be DateTime objects (" . ref($dt) . ")" ) unless ( ref($dt) eq 'DateTime' ); my ( undef, $tmp_set ) = _sunrise( $self, $dt ); return $tmp_set if $tmp_set > $dt; my $d = DateTime::Duration->new( days => 1, ); my $new_dt = $dt + $d; ( undef, $tmp_set ) = _sunrise( $self, $new_dt ); return $tmp_set if $tmp_set > $dt; $new_dt = $new_dt + $d; ( undef, $tmp_set ) = _sunrise( $self, $new_dt ); return $tmp_set; } # # # FUNCTIONAL SEQUENCE for _previous_sunset # # _GIVEN # A sunrise object # A DateTime object # # _THEN # # Validate the DateTime Object # Compute sunset and return if it is less than # the original object if not subtract one day and recompute # # _RETURN # # A DateTime object with sunset time # sub _previous_sunset { my $self = shift; my $dt = shift; croak( "Dates need to be DateTime objects (" . ref($dt) . ")" ) unless ( $dt->isa('DateTime') ); my ( undef, $tmp_set ) = _sunrise( $self, $dt ); return $tmp_set if $tmp_set < $dt; my $d = DateTime::Duration->new( days => 1, ); my $new_dt = $dt - $d; ( undef, $tmp_set ) = _sunrise( $self, $new_dt ); return $tmp_set if $tmp_set < $dt; $new_dt = $new_dt - $d; ( undef, $tmp_set ) = _sunrise( $self, $new_dt ); return $tmp_set; } # # # FUNCTIONAL SEQUENCE for _sunrise # # _GIVEN # A sunrise object and a DateTime object # # _THEN # # Check if precise is set to one if so # initially compute sunrise/sunset (using division # by 15.04107 instead of 15.0) then recompute rise/set time # using exact moment last computed. IF precise is set # to zero devide by 15.0 (only once) # # Bug in this sub, I was blindly setting the hour and min without # checking if it was neg. a neg. value for hours/min is not correct # I changed the routine to use a duration then add the duration. # # _RETURN # # two DateTime objects with the date and time for sunrise and sunset # two season flags for sunrise and sunset respectively # sub _sunrise { my ($self, $dt, $silent) = @_; my $cloned_dt = $dt->clone; my $altit = $self->{altitude}; my $precise = defined( $self->{precise} ) ? $self->{precise} : 0; unless (defined $silent) { $silent = defined( $self->{silent} ) ? $self->{silent} : 0; } $cloned_dt->set_time_zone('floating'); if ($precise) { # This is the initial start my $d = days_since_2000_Jan_0($cloned_dt) + 0.5 - $self->{longitude} / 360.0; my ($tmp_rise_1, $tmp_set_1, $rise_season) = _sunrise_sunset( $d, $self->{longitude}, $self->{latitude}, $altit, 15.04107, $self->{upper_limb}, $silent); my $set_season = $rise_season; # Now we have the initial rise/set times next recompute d using the exact moment # recompute sunrise my $tmp_rise_2 = 9; my $tmp_rise_3 = 0; my $counter = 0; until ( equal( $tmp_rise_2, $tmp_rise_3, 8 ) ) { my $d_sunrise_1 = $d + $tmp_rise_1 / 24.0; ($tmp_rise_2, undef, undef) = _sunrise_sunset($d_sunrise_1, $self->{longitude}, $self->{latitude}, $altit, 15.04107, $self->{upper_limb}, $silent); $tmp_rise_1 = $tmp_rise_3; my $d_sunrise_2 = $d + $tmp_rise_2 / 24.0; ($tmp_rise_3, undef, $rise_season) = _sunrise_sunset($d_sunrise_2, $self->{longitude}, $self->{latitude}, $altit, 15.04107, $self->{upper_limb}, $silent); last if ++$counter > 10; } my $tmp_set_2 = 9; my $tmp_set_3 = 0; $counter = 0; until ( equal( $tmp_set_2, $tmp_set_3, 8 ) ) { my $d_sunset_1 = $d + $tmp_set_1 / 24.0; (undef, $tmp_set_2, undef) = _sunrise_sunset( $d_sunset_1, $self->{longitude}, $self->{latitude}, $altit, 15.04107, $self->{upper_limb}, $silent); $tmp_set_1 = $tmp_set_3; my $d_sunset_2 = $d + $tmp_set_2 / 24.0; (undef, $tmp_set_3, $set_season) = _sunrise_sunset( $d_sunset_2, $self->{longitude}, $self->{latitude}, $altit, 15.04107, $self->{upper_limb}, $silent); last if ++$counter > 10; } my ( $second_rise, $second_set ) = convert_hour( $tmp_rise_3, $tmp_set_3 ); # This is to fix the datetime object to use a duration # instead of blindly setting the hour/min my $rise_dur = DateTime::Duration->new( seconds => $second_rise ); my $set_dur = DateTime::Duration->new( seconds => $second_set ); my $tmp_dt1 = DateTime->new( year => $dt->year, month => $dt->month, day => $dt->day, hour => 0, minute => 0, time_zone => 'UTC' ); my $rise_time = $tmp_dt1 + $rise_dur; my $set_time = $tmp_dt1 + $set_dur; my $tz = $dt->time_zone; $rise_time->set_time_zone($tz) unless $tz->is_floating; $set_time->set_time_zone($tz) unless $tz->is_floating; return ( $rise_time, $set_time, $rise_season, $set_season ); } else { my $d = days_since_2000_Jan_0($cloned_dt) + 0.5 - $self->{longitude} / 360.0; my ( $h1, $h2, $season ) = _sunrise_sunset( $d, $self->{longitude}, $self->{latitude}, $altit, 15.0, $self->{upper_limb}, $silent); my ( $seconds_rise, $seconds_set ) = convert_hour( $h1, $h2 ); my $rise_dur = DateTime::Duration->new( seconds => $seconds_rise ); my $set_dur = DateTime::Duration->new( seconds => $seconds_set ); my $tmp_dt1 = DateTime->new( year => $dt->year, month => $dt->month, day => $dt->day, hour => 0, minute => 0, time_zone => 'UTC' ); my $rise_time = $tmp_dt1 + $rise_dur; my $set_time = $tmp_dt1 + $set_dur; my $tz = $dt->time_zone; $rise_time->set_time_zone($tz) unless $tz->is_floating; $set_time->set_time_zone($tz) unless $tz->is_floating; return ( $rise_time, $set_time, $season, $season ); } } # # # FUNCTIONAL SEQUENCE for _sunrise_sunset # # _GIVEN # # days since Jan 0 2000, longitude, latitude, reference sun height $h and the "upper limb" and "silent" flags # _THEN # # Compute the sunrise/sunset times for that day # # _RETURN # # sunrise and sunset times as hours (GMT Time) # season flag: -1 for polar night, +1 for midnight sun, 0 for day and night # sub _sunrise_sunset { my ( $d, $lon, $lat, $altit, $h, $upper_limb, $silent ) = @_; # Compute local sidereal time of this moment my $sidtime = revolution(GMST0($d) + 180.0 + $lon); # Compute Sun's RA + Decl + distance at this moment my ($sRA, $sdec, $sr) = sun_RA_dec($d); # Compute time when Sun is at south - in hours UT my $tsouth = 12.0 - rev180( $sidtime - $sRA ) / $h; # Compute the Sun's apparent radius, degrees my $sradius = 0.2666 / $sr; # Do correction to upper limb, if necessary if ($upper_limb) { $altit -= $sradius; } # Compute the diurnal arc that the Sun traverses to reach # the specified height altit: my $cost = (sind($altit) - sind($lat) * sind($sdec)) / (cosd($lat) * cosd($sdec)); my $t; my $season = 0; if ( $cost >= 1.0 ) { unless ($silent) { carp "Sun never rises!!\n"; } $t = 0.0; # Sun always below altit $season = -1; } elsif ( $cost <= -1.0 ) { unless ($silent) { carp "Sun never sets!!\n"; } $t = 12.0; # Sun always above altit $season = +1; } else { $t = acosd($cost) / 15.0; # The diurnal arc, hours } # Store rise and set times - in hours UT my $hour_rise_ut = $tsouth - $t; my $hour_set_ut = $tsouth + $t; return ( $hour_rise_ut, $hour_set_ut, $season ); } # # # FUNCTIONAL SEQUENCE for GMST0 # # _GIVEN # Day number # # _THEN # # computes GMST0, the Greenwich Mean Sidereal Time # at 0h UT (i.e. the sidereal time at the Greenwhich meridian at # 0h UT). GMST is then the sidereal time at Greenwich at any # time of the day. # # # _RETURN # # Sidtime # sub GMST0 { my ($d) = @_; my $sidtim0 = revolution( ( 180.0 + 356.0470 + 282.9404 ) + ( 0.9856002585 + 4.70935E-5 ) * $d ); return $sidtim0; } # # # FUNCTIONAL SEQUENCE for sunpos # # _GIVEN # day number # # _THEN # # Computes the Sun's ecliptic longitude and distance # at an instant given in d, number of days since # 2000 Jan 0.0. # # # _RETURN # # ecliptic longitude and distance # ie. $True_solar_longitude, $Solar_distance # sub sunpos { my ($d) = @_; # Mean anomaly of the Sun # Mean longitude of perihelion # Note: Sun's mean longitude = M + w # Eccentricity of Earth's orbit # Eccentric anomaly # x, y coordinates in orbit # True anomaly # Compute mean elements my $Mean_anomaly_of_sun = revolution( 356.0470 + 0.9856002585 * $d ); my $Mean_longitude_of_perihelion = 282.9404 + 4.70935E-5 * $d; my $Eccentricity_of_Earth_orbit = 0.016709 - 1.151E-9 * $d; # Compute true longitude and radius vector my $Eccentric_anomaly = $Mean_anomaly_of_sun + $Eccentricity_of_Earth_orbit * $RADEG * sind($Mean_anomaly_of_sun) * ( 1.0 + $Eccentricity_of_Earth_orbit * cosd($Mean_anomaly_of_sun) ); my $x = cosd($Eccentric_anomaly) - $Eccentricity_of_Earth_orbit; my $y = sqrt( 1.0 - $Eccentricity_of_Earth_orbit * $Eccentricity_of_Earth_orbit ) * sind($Eccentric_anomaly); my $Solar_distance = sqrt( $x * $x + $y * $y ); # Solar distance my $True_anomaly = atan2d( $y, $x ); # True anomaly my $True_solar_longitude = $True_anomaly + $Mean_longitude_of_perihelion; # True solar longitude if ( $True_solar_longitude >= 360.0 ) { $True_solar_longitude -= 360.0; # Make it 0..360 degrees } return ( $Solar_distance, $True_solar_longitude ); } # # # FUNCTIONAL SEQUENCE for sun_RA_dec # # _GIVEN # day number, $r and $lon (from sunpos) # # _THEN # # compute RA and dec # # # _RETURN # # Sun's Right Ascension (RA), Declination (dec) and distance (r) # # sub sun_RA_dec { my ($d) = @_; # Compute Sun's ecliptical coordinates my ( $r, $lon ) = sunpos($d); # Compute ecliptic rectangular coordinates (z=0) my $x = $r * cosd($lon); my $y = $r * sind($lon); # Compute obliquity of ecliptic (inclination of Earth's axis) my $obl_ecl = 23.4393 - 3.563E-7 * $d; # Convert to equatorial rectangular coordinates - x is unchanged my $z = $y * sind($obl_ecl); $y = $y * cosd($obl_ecl); # Convert to spherical coordinates my $RA = atan2d( $y, $x ); my $dec = atan2d( $z, sqrt( $x * $x + $y * $y ) ); return ( $RA, $dec, $r ); } # sun_RA_dec # # # FUNCTIONAL SEQUENCE for days_since_2000_Jan_0 # # _GIVEN # A Datetime object # # _THEN # # process the DateTime object for number of days # since Jan,1 2000 (counted in days) # Day 0.0 is at Jan 1 2000 0.0 UT # # _RETURN # # day number # sub days_since_2000_Jan_0 { my ($dt) = @_; return int($dt->jd - $jd_2000_Jan_0); } sub sind { sin( ( $_[0] ) * $DEGRAD ); } sub cosd { cos( ( $_[0] ) * $DEGRAD ); } sub tand { tan( ( $_[0] ) * $DEGRAD ); } sub atand { ( $RADEG * atan( $_[0] ) ); } sub asind { ( $RADEG * asin( $_[0] ) ); } sub acosd { ( $RADEG * acos( $_[0] ) ); } sub atan2d { ( $RADEG * atan2( $_[0], $_[1] ) ); } # # # FUNCTIONAL SEQUENCE for revolution # # _GIVEN # any angle in degrees # # _THEN # # reduces any angle to within the first revolution # by subtracting or adding even multiples of 360.0 # # # _RETURN # # the value of the input is >= 0.0 and < 360.0 # sub revolution { my $x = $_[0]; return ( $x - 360.0 * floor( $x * $INV360 ) ); } # # # FUNCTIONAL SEQUENCE for rev180 # # _GIVEN # # any angle in degrees # # _THEN # # Reduce input to within +180..+180 degrees # # # _RETURN # # angle that was reduced # sub rev180 { my ($x) = @_; return ( $x - 360.0 * floor( $x * $INV360 + 0.5 ) ); } # # # FUNCTIONAL SEQUENCE for equal # # _GIVEN # # Two floating point numbers and Accuracy # # _THEN # # Use sprintf to format the numbers to Accuracy # number of decimal places # # _RETURN # # True if the numbers are equal # sub equal { my ( $A, $B, $dp ) = @_; return sprintf( "%.${dp}g", $A ) eq sprintf( "%.${dp}g", $B ); } # # # FUNCTIONAL SEQUENCE for convert_hour # # _GIVEN # Hour_rise, Hour_set # hours are in UT # # _THEN # # split out the hours and minutes # Oct 20 2003 # will convert hours to seconds and return this # let DateTime handle the conversion # # _RETURN # # number of seconds sub convert_hour { my ( $hour_rise_ut, $hour_set_ut ) = @_; my $seconds_rise = floor( $hour_rise_ut * 60 * 60 ); my $seconds_set = floor( $hour_set_ut * 60 * 60 ); return ( $seconds_rise, $seconds_set ); } 1962; # Hint: sung by RZ, better known as BD =encoding utf8 =head1 NAME DateTime::Event::Sunrise - Perl DateTime extension for computing the sunrise/sunset on a given day =head1 SYNOPSIS use DateTime; use DateTime::Event::Sunrise; # generating DateTime objects from a DateTime::Event::Sunrise object my $sun_Kyiv = DateTime::Event::Sunrise->new(longitude => +30.85, # 30°51'E latitude => +50.45); # 50°27'N for (12, 13, 14) { my $dt_yapc_eu = DateTime->new(year => 2013, month => 8, day => $_, time_zone => 'Europe/Kiev'); say "In Kyiv (50°27'N, 30°51'E) on ", $dt_yapc_eu->ymd, " sunrise occurs at ", $sun_Kyiv->sunrise_datetime($dt_yapc_eu)->hms, " and sunset occurs at ", $sun_Kyiv->sunset_datetime ($dt_yapc_eu)->hms; } # generating DateTime objects from DateTime::Set objects my $sunrise_Austin = DateTime::Event::Sunrise->sunrise(longitude => -94.73, # 97°44'W latitude => +30.3); # 30°18'N my $sunset_Austin = DateTime::Event::Sunrise->sunset (longitude => -94.73, latitude => +30.3); my $dt_yapc_na_rise = DateTime->new(year => 2013, month => 6, day => 3, time_zone => 'America/Chicago'); my $dt_yapc_na_set = $dt_yapc_na_rise->clone; say "In Austin (30°18'N, 97°44'W), sunrises and sunsets are"; for (1..3) { $dt_yapc_na_rise = $sunrise_Austin->next($dt_yapc_na_rise); $dt_yapc_na_set = $sunset_Austin ->next($dt_yapc_na_set); say $dt_yapc_na_rise, ' ', $dt_yapc_na_set; } # If you deal with a polar location my $sun_in_Halley = DateTime::Event::Sunrise->new( longitude => -26.65, # 26°39'W latitude => -75.58, # 75°35'S precise => 1, ); my $Alex_arrival = DateTime->new(year => 2006, # approximate date, not necessarily the exact one month => 1, day => 15, time_zone => 'Antarctica/Rothera'); say $Alex_arrival->strftime("Alex Gough (a Perl programmer) arrived at Halley Base on %Y-%m-%d."); if ($sun_in_Halley->is_polar_day($Alex_arrival)) { say "It would be days, maybe weeks, before the sun would set."; } elsif ($sun_in_Halley->is_polar_night($Alex_arrival)) { say "It would be days, maybe weeks, before the sun would rise."; } else { my $sunset = $sun_in_Halley->sunset_datetime($Alex_arrival); say $sunset->strftime("And he saw his first antarctic sunset at %H:%M:%S."); } =head1 DESCRIPTION This module will computes the time of sunrise and sunset for a given date and a given location. The computation uses Paul Schlyter's algorithm. Actually, the module creates a DateTime::Event::Sunrise object or a DateTime::Set object, which are used to generate the sunrise or the sunset times for a given location and for any date. =head1 METHODS =head2 new This is the DateTime::Event::Sunrise constructor. It takes keyword parameters, which are: =over 4 =item longitude This is the longitude of the location where the sunrises and sunsets are observed. It is given as decimal degrees: no minutes, no seconds, but tenths and hundredths of degrees. Another break with the normal usage is that Eastern longitude are positive, Western longitudes are negative. Default value is 0, that is Greenwich or any location on the eponymous meridian. =item latitude This is the latitude of the location where the sunrises and sunsets are observed. As for the longitude, it is given as decimal degrees. Northern latitudes are positive numbers, Southern latitudes are negative numbers. Default value is 0, that is any location on the equator. =item altitude This is the height of the Sun at sunrise or sunset. In astronomical context, the altitude or height is the angle between the Sun and the local horizon. It is expressed as degrees, usually with a negative number, since the Sun is I the horizon. Default value is -0.833, that is when the sun's upper limb touches the horizon, while taking in account the light refraction. Positive altitude are allowed, in case the location is near a mountain range behind which the sun rises or sets. =item precise Boolean to control which algorithm is used. A false value gives a simple algorithm, but which can lead to inaccurate sunrise times and sunset times. A true value gives a more elaborate algorithm, with a loop to refine the sunrise and sunset times and obtain a better precision. Default value is 0, to choose the simple algorithm. This parameter replaces the C deprecated parameter. =item upper_limb Boolean to choose between checking the Sun's upper limb or its center. A true value selects the upper limb, a false value selects the center. This parameter is significant only when the altitude does not already deal with the sun radius. When the altitude takes into account the sun radius, this parameter should be false. Default value is 0, since the upper limb correction is already taken in account with the default -0.833 altitude. =item silent Boolean to control the output of some warning messages. With polar locations and dates near the winter solstice or the summer solstice, it may happen that the sun never rises above the horizon or never sets below. If this parameter is set to false, the module will send warnings for these conditions. If this parameter is set to true, the module will not pollute your F stream. Default value is 0, for backward compatibility. =back =head2 sunrise, sunset Although they come from the DateTime::Event::Sunrise module, these methods are C constructors. They use the same parameters as the C constructor, but they give objects from a different class. =head2 sunrise_datetime, sunset_datetime These two methods apply to C objects (that is, created with C, not C or C). They receive one parameter in addition to C<$self>, a C object. They return another C object, for the same day, but with the time of the sunrise or sunset, respectively. =head2 sunrise_sunset_span This method applies to C objects. It accepts a C object as the second parameter. It returns a C object, beginning at sunrise and ending at sunset. =head2 is_polar_night, is_polar_day, is_day_and_night These methods apply to C objects. They accept a C object as the second parameter. They return a boolean indicating the following condutions: =over 4 =item * is_polar_night is true when the sun stays under the horizon. Or rather under the altitude parameter used when the C object was created. =item * is_polar_day is true when the sun stays above the horizon, resulting in a "Midnight sun". Or rather when it stays above the altitude parameter used when the C object was created. =item * is_day_and_night is true when neither is_polar_day, nor is_polar_night are true. =back =head2 next current previous contains as_list iterator See DateTime::Set. =head1 EXTENDED EXAMPLES my $dt = DateTime->new( year => 2000, month => 6, day => 20, ); my $sunrise = DateTime::Event::Sunrise ->sunrise ( longitude =>'-118', latitude =>'33', altitude => '-0.833', precise => '1' ); my $sunset = DateTime::Event::Sunrise ->sunset ( longitude =>'-118', latitude =>'33', altitude => '-0.833', precise => '1' ); my $tmp_rise = $sunrise->next( $dt ); my $dt2 = DateTime->new( year => 2000, month => 12, day => 31, ); # iterator my $dt_span = DateTime::Span->new( start =>$dt, end=>$dt2 ); my $set = $sunrise->intersection($dt_span); my $iter = $set->iterator; while ( my $dt = $iter->next ) { print ' ',$dt->datetime; } # is it day or night? my $day_set = DateTime::SpanSet->from_sets( start_set => $sunrise, end_set => $sunset ); print $day_set->contains( $dt ) ? 'day' : 'night'; my $dt = DateTime->new( year => 2000, month => 6, day => 20, time_zone => 'America/Los_Angeles', ); my $sunrise = DateTime::Event::Sunrise ->new( longitude =>'-118' , latitude => '33', altitude => '-0.833', precise => '1' ); my $tmp = $sunrise->sunrise_sunset_span($dt); print "Sunrise is:" , $tmp->start->datetime , "\n"; print "Sunset is:" , $tmp->end->datetime; =head1 NOTES =head2 Longitude Signs Remember, contrary to the usual convention, EASTERN longitudes are POSITIVE, WESTERN longitudes are NEGATIVE. On the other hand, the latitude signs follow the usual convention: Northen latitudes are positive, Southern latitudes are negative. =head2 Sun Height There are a number of sun heights to choose from. The default is -0.833 because this is what most countries use. Feel free to specify it if you need to. Here is the list of values to specify the sun height with: =over 4 =item * B<0> degrees Center of Sun's disk touches a mathematical horizon =item * B<-0.25> degrees Sun's upper limb touches a mathematical horizon =item * B<-0.583> degrees Center of Sun's disk touches the horizon; atmospheric refraction accounted for =item * B<-0.833> degrees Sun's supper limb touches the horizon; atmospheric refraction accounted for =item * B<-6> degrees Civil twilight (one can no longer read outside without artificial illumination) =item * B<-12> degrees Nautical twilight (navigation using a sea horizon no longer possible) =item * B<-15> degrees Amateur astronomical twilight (the sky is dark enough for most astronomical observations) =item * B<-18> degrees Astronomical twilight (the sky is completely dark) =back =head2 Notes on the Precise Algorithm The original method only gives an approximate value of the Sun's rise/set times. The error rarely exceeds one or two minutes, but at high latitudes, when the Midnight Sun soon will start or just has ended, the errors may be much larger. If you want higher accuracy, you must then select the precise variant of the algorithm. This feature is new as of version 0.7. Here is what I have tried to accomplish with this. =over 4 =item a) Compute sunrise or sunset as always, with one exception: to convert LHA from degrees to hours, divide by 15.04107 instead of 15.0 (this accounts for the difference between the solar day and the sidereal day. =item b) Re-do the computation but compute the Sun's RA and Decl, and also GMST0, for the moment of sunrise or sunset last computed. =item c) Iterate b) until the computed sunrise or sunset no longer changes significantly. Usually 2 iterations are enough, in rare cases 3 or 4 iterations may be needed. =back =head2 Notes on polar locations If the location is beyond either polar circle, and if the date is near either solstice, there can be midnight sun or polar night. In this case, there is neither sunrise nor sunset, and the module Cs that the sun never rises or never sets. Then, it returns the time at which the sun is at its highest or lowest point. =head1 DEPENDENCIES This module requires: =over 4 =item * DateTime =item * DateTime::Set =item * DateTime::Span =item * Params::Validate =item * Set::Infinite =item * POSIX =item * Math::Trig =back =head1 BUGS AND CAVEATS Using a latitude of 90 degrees (North Pole or South Pole) gives curious results. I guess that it is linked with a ambiguous value resulting from a 0/0 computation. Using a longitude of 177 degrees, or any longitude near the 180 meridian, may also give curious results, especially with the precise algorithm. The precise algorithm should be overhauled. =head1 AUTHORS Original author: Ron Hill Co-maintainer: Jean Forget =head1 SPECIAL THANKS =over 4 =item Robert Creager [Astro-Sunrise@LogicalChaos.org] for providing help with converting Paul's C code to perl. =item Flávio S. Glock [fglock@pucrs.br] for providing the the interface to the DateTime::Set module. =back =head1 CREDITS =over 4 =item Paul Schlyter, Stockholm, Sweden for his excellent web page on the subject. =item Rich Bowen (rbowen@rbowen.com) for suggestions. =item People at L for noticing an endless loop condition in L and for fixing it. =back =head1 COPYRIGHT and LICENSE =head2 Perl Module This program is distributed under the same terms as Perl 5.16.3: GNU Public License version 1 or later and Perl Artistic License You can find the text of the licenses in the F file or at L and L. Here is the summary of GPL: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. =head2 Original C program Here is the copyright information provided by Paul Schlyter for the original C program: Written as DAYLEN.C, 1989-08-16 Modified to SUNRISET.C, 1992-12-01 (c) Paul Schlyter, 1989, 1992 Released to the public domain by Paul Schlyter, December 1992 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =head1 SEE ALSO perl(1). DateTime Web page at http://datetime.perl.org/ DateTime::Set DateTime::SpanSet Astro::Sunrise DateTime::Event::Jewish::Sunrise Paul Schlyter's homepage at http://stjarnhimlen.se/english.html =cut DateTime-Event-Sunrise-0.0505/README0000644000175000017500000000240112631364541014446 0ustar jfjfDateTime/Event/Sunrise version 0.0505 ===================================== This module will return a DateTime Object for sunrise and sunset for a given day. To install this module type the following: perl Makefile.PL make make test make install or use your favorite utility: CPAN shell, cpanplus, cpanminus, dist-zilla, etc. Note: do not be disturbed by warnings "sun never rises" or "sun never sets" during "make test". They are nothing more than warnings. DEPENDENCIES This module requires these other modules and libraries: DateTime.pm DateTime::Set DateTime::Duration DateTime::Span DateTime::SpanSet POSIX Math::Trig Carp Params::Validate Set::Infinite Test::More Test::Exception COPYRIGHT AND LICENCE Copyright (C) 2003, 2013, 2015 Ron Hill and Jean Forget This library is free software; you can redistribute it and/or modify it under the same terms as Perl 5.16.3. For more details, see the full text of the licenses in the LICENSE file. This program is distributed in the hope that it will be useful, but it is provided “as is” and without any express or implied warranties. For details, see the full text of the licenses in the file LICENSE. Based on a public domain C program sunriset.c (c) Paul Schlyter, 1989, 1992 DateTime-Event-Sunrise-0.0505/LICENSE0000644000175000017500000004556712046645474014626 0ustar jfjfTerms of Perl itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --------------------------------------------------------------------------- GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --------------------------------------------------------------------------- The "Artistic License" Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder as specified below. "Copyright Holder" is whoever is named in the copyright or copyrights for the package. "You" is you, if you're thinking about copying or distributing this Package. "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as uunet.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) give non-standard executables non-standard names, and clearly document the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End DateTime-Event-Sunrise-0.0505/Changes0000644000175000017500000000563012631370540015064 0ustar jfjfRevision history for Perl extension DateTime::Event::Sunrise. 0.0505 Mon 2015-12-07 - Fix ticket 110016, to prevent endless loops (thank you http://geocoder.opencagedata.com/) Actually a stop-gap measure, until the overhaul of the precise algorithm. 0.0504 Thu 2014-07-24 - add the "is_polar_night", "is_polar_day" and "is_day_and_night" boolean methods, one half of fixing ticket RT91783 - add a "silent" build parameter, which removes the warnings about the sun never rising / never setting the other half of fixing ticket RT91783 - add a test file for the parameter checking 0.0503 Thu 2013-10-17 - stylistic and kwalitee issues: license, dependencies, use warnings - fix typos in the comments and POD and use UTF-8 - fix _following_sunrise, _previous_sunrise, _following_sunset, _previous_sunset (ticket 36352) - deprecate "iteration" keyword, replaced by "precise" (ticket 77710) - allow any height, not only the standard ones (ticket 8065) - add an "upper_limb" parameter - some test data are computed by a C program based on Paul Schlyter's code 0.0502 Mon 2013-07-08 - fixed computation error visible on 19, 20, 21 and 22 March (tickets 34770, 55762 and 75927) - improve object class check (ticket 7605) - a few words in POD about polar night and midnight sun 0.0501 Wed Mar 31 2004 - added fix for DateTime-Set after 0.1402 - I had to remove one test (the span set test) I need to check to see what is going on I think I need to rewrite this test 0.05 Fri Jan 9 2004 - Added sunrise_sunset_span method. This will return rise/set time for one day (as a span object). Request # 4785 on rt.cpan.org Added sunrise_datetime, sunset_datetime method. 0.0402 Tues, Nov 25 2003 - Changed the convert_hour to convert to seconds (as a duration) Then add the duration to the day. This will provide seconds for the DateTime Object. - Added many tests (Cities around the world). I have verified the entries in the data section of the tests within +- 2 min. using the information from the Naval Observatory (aa.usno.navy.mil). 0.0401 Thurs Oct 8 2003 - changed the _sunrise sub to include the timezone information - (I don't like the way I did this needs more research) 0.04 Fri May 30 7:40 2003 - Fixed a bug in _sunrise The problem was I was setting the hours/min for the rise/set times I needed to create a duration and add the duration to the DateTime Object. 0.03 Tues April 29 14:00 2003 - initial release to CPAN 0.02 Mon April 21 13:20:00 2003 - doc tweaks. Flavio S. Glock - renamed sun_rise_set to sunrise_sunset - gets methods from DateTime::Set 0.01 Mon Mar 21 10:01:50 2003 - original version; created by Ron Hill DateTime-Event-Sunrise-0.0505/MANIFEST0000644000175000017500000000052612631373464014731 0ustar jfjfChanges LICENSE Makefile.PL MANIFEST README TODO lib/DateTime/Event/Sunrise.pm t/00load.t t/01basic.t t/02March21.t t/03nextprev.t t/04basic.t t/05polar.t t/06checks.t t/07loop.t META.yml Module meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) DateTime-Event-Sunrise-0.0505/META.json0000664000175000017500000000262212631373464015222 0ustar jfjf{ "abstract" : "Perl DateTime extension for computing the sunrise/sunset on a given day", "author" : [ "Ron Hill ", "Jean Forget " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "DateTime-Event-Sunrise", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "6.57_02", "Test::More" : "0" } }, "runtime" : { "requires" : { "DateTime" : "0.16", "DateTime::Duration" : "0", "DateTime::Span" : "0", "DateTime::SpanSet" : "0", "perl" : "v5.8.5" } } }, "provides" : { "DateTime::Event::Sunrise" : { "file" : "lib/DateTime/Event/Sunrise.pm", "version" : "0.0505" } }, "release_status" : "stable", "resources" : { "repository" : { "type" : "git", "url" : "https://github.com/jforget/DateTime-Event-Sunrise.git", "web" : "https://github.com/jforget/DateTime-Event-Sunrise" } }, "version" : "0.0505" } DateTime-Event-Sunrise-0.0505/META.yml0000664000175000017500000000146312631373464015054 0ustar jfjf--- abstract: 'Perl DateTime extension for computing the sunrise/sunset on a given day' author: - 'Ron Hill ' - 'Jean Forget ' build_requires: ExtUtils::MakeMaker: 6.57_02 Test::More: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120630' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: DateTime-Event-Sunrise no_index: directory: - t - inc provides: DateTime::Event::Sunrise: file: lib/DateTime/Event/Sunrise.pm version: 0.0505 requires: DateTime: 0.16 DateTime::Duration: 0 DateTime::Span: 0 DateTime::SpanSet: 0 perl: v5.8.5 resources: repository: https://github.com/jforget/DateTime-Event-Sunrise.git version: 0.0505