monarch has asked for the wisdom of the Perl Monks concerning the following question:
use DateTime; use DateTime::Event::Sunrise; use strict; my $timezone = "Pacific/Auckland"; my ( $latitude, $longitude ) = ( -36.55, 174.45 ); my $dt_start = DateTime->new( year => 2006, month => 3, day => 1, hour => 4, time_zone => $timezone, ); my $dt_end = $dt_start->clone()->add(days=>31); for ( my $dt = $dt_start->clone(); $dt < $dt_end; $dt->add(days=>1) ) { my $sset = DateTime::Event::Sunrise->sunset( longitude => $longitude, latitude => $latitude, altitude => '-0.833', iteration => '1' ); my $dt_ss = $sset->next($dt); print( "Sunset on " . $dt->strftime("%d %B %Y") . " at " . $dt_ss->strftime("%H:%M") . "\n" ); }
This code prints out the sunset time for each day of March 2006 in Auckland, New Zealand.
When running this code it complains that the sun never sets on 22 March 2006, which is clearly not the case in Auckland.
Running the above code with the sunset object set to iteration => '0' works fine (although less accurately).
Any ideas why I'm getting this:
Sunset on 19 March 2006 at 18:38 Sunset on 20 March 2006 at 18:36 Sunset on 21 March 2006 at 18:33 Sun never sets!! at /usr/lib/perl5/vendor_perl/5.8.5/DateTime/Set.pm line 240 Sun never sets!! at /usr/lib/perl5/vendor_perl/5.8.5/DateTime/Set.pm line 240 Sun never rises!! at /usr/lib/perl5/vendor_perl/5.8.5/DateTime/Set.pm line 240 Sun never rises!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sun Never Sets
by idsfa (Vicar) on Feb 20, 2006 at 02:50 UTC | |
|
Re: Sun Never Sets
by bart (Canon) on Feb 20, 2006 at 00:47 UTC | |
by monarch (Priest) on Feb 20, 2006 at 00:54 UTC | |
|
Re: Sun Never Sets
by spiritway (Vicar) on Feb 19, 2006 at 23:58 UTC | |
by monarch (Priest) on Feb 20, 2006 at 02:16 UTC | |
by Anonymous Monk on Mar 17, 2012 at 03:20 UTC | |
by Anonymous Monk on Sep 10, 2012 at 05:29 UTC | |
|
Re: Sun Never Sets
by Eradicatore (Monk) on Dec 17, 2012 at 07:14 UTC |