Bug#693704: libdatetime-astro-sunrise-perl: Fails if sunrise and set not in same day

Dick Middleton dick at lingbrae.com
Mon Nov 19 14:27:55 UTC 2012


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!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sunrise.patch
Type: text/x-diff
Size: 2783 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-perl-maintainers/attachments/20121119/ab28ccca/attachment.patch>


More information about the pkg-perl-maintainers mailing list