Package: libdatetime-astro-sunrise-perl Version: 0.01.01-3 Severity: important
Dear Maintainer, If I use $sunrise = DateTime::Astro::Sunrise->new( $long, $lat, -0.583, 0); ($rise, $set) = $sunrise->sunrise($dt); where lat/long are in Australia and date is about now (19th Nov 2012) the method sunrise fails The 'minute' parameter ("-59") to DateTime::new did not pass the 'an integer between 0 and 59' callback at /usr/lib/perl5/DateTime.pm line 199 DateTime::new(undef, 'year', 2012, 'month', 11, 'day', 19, 'hour', 20, ...) called at /usr/share/perl5/DateTime/Astro/Sunrise.pm line 129 This is because sunrise is on the day before sunset in UTC and sunrise uses negative numbers as arguments to datetime->new for hour and minute. The fix seems to be to use the math capability of DateTime to set the hour and minute: my $rise_time = DateTime->new( year => $dt->year, month => $dt->month, day => $dt->day, hour => 0, minute => 0, time_zone => 'UTC')->add(hours=>$hour_rise, minutes => $min_rise); in the 4 places where the times are initialized. Patch attached but all I can say is 'it works for me'. I've tested it in any generalised way. -- System Information: Debian Release: wheezy/sid APT prefers testing APT policy: (500, 'testing'), (500, 'stable') Architecture: i386 (i686) Kernel: Linux 3.2.0-3-686-pae (SMP w/2 CPU cores) Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Shell: /bin/sh linked to /bin/bash Versions of packages libdatetime-astro-sunrise-perl depends on: ii libdatetime-perl 2:0.7500-1 ii perl 5.14.2-13 libdatetime-astro-sunrise-perl recommends no packages. libdatetime-astro-sunrise-perl suggests no packages. -- no debconf information -- debsums errors found: debsums: changed file /usr/share/perl5/DateTime/Astro/Sunrise.pm (from libdatetime-astro-sunrise-perl package) That's because I've modified it!
--- Sunrise.bak 2012-11-19 13:42:13.724006946 +0000 +++ Sunrise.pm 2012-11-19 14:21:30.536744605 +0000 @@ -40,7 +40,6 @@ my ( $year, $month, $day ) = ( $dt->year, $dt->month, $dt->day ); my $altit = $self->{ALT} || -0.833; my $iteration = defined( $self->{ITER} ) ? $self->{ITER} : 0; - if ($iteration) { # This is the initial start @@ -102,22 +101,24 @@ my ( $hour_rise, $min_rise, $hour_set, $min_set ) = convert_hour($tmp_rise_3,$tmp_set_3); my $rise_time = DateTime->new( - year => $dt->year, - month => $dt->month, - day => $dt->day, - hour => $hour_rise % 24, - minute => $min_rise, - time_zone => 'UTC' - ); + year => $dt->year, + month => $dt->month, + day => $dt->day, + hour => 0, + minute => 0, + time_zone => 'UTC')->add(hours=>$hour_rise, + minutes => $min_rise + ); my $set_time = DateTime->new( - year => $dt->year, - month => $dt->month, - day => $dt->day, - hour => $hour_set % 24, - minute => $min_set, - time_zone => 'UTC' - ); - return ($rise_time, $set_time); + year => $dt->year, + month => $dt->month, + day => $dt->day, + hour => 0, + minute => 0, + time_zone => 'UTC')->add(hours=>$hour_set, + minutes => $min_set + ); + return ($rise_time, $set_time); } else { my $d = @@ -127,23 +128,24 @@ sun_rise_set( $d, $self->{LON}, $self->{LAT}, $altit, 15.0 ); my ( $hour_rise, $min_rise, $hour_set, $min_set ) = convert_hour( $h1, $h2 ); - my $rise_time = DateTime->new( - year => $dt->year, - month => $dt->month, - day => $dt->day, - hour => $hour_rise % 24, - minute => $min_rise, - time_zone => 'UTC' - ); + year => $dt->year, + month => $dt->month, + day => $dt->day, + hour => 0, + minute => 0, + time_zone => 'UTC')->add(hours=>$hour_rise, + minutes => $min_rise + ); my $set_time = DateTime->new( - year => $dt->year, - month => $dt->month, - day => $dt->day, - hour => $hour_set % 24, - minute => $min_set, - time_zone => 'UTC' - ); + year => $dt->year, + month => $dt->month, + day => $dt->day, + hour => 0, + minute => 0, + time_zone => 'UTC')->add(hours=>$hour_set, + minutes => $min_set + ); return ($rise_time, $set_time); }