I have some code:
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!!

In reply to Sun Never Sets by monarch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.