Skip Menu |

This queue is for tickets about the Astro-Sunrise CPAN distribution.

Report information
The Basics
Id: 62593
Status: resolved
Priority: 0/
Queue: Astro-Sunrise

People
Owner: J2N-FORGET [...] orange.fr
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.91
Fixed in: 0.94



Subject: sun_rise/set return wrong values on days with DST change
Today I got a wrong result for the sun_set time in Berlin. Here's a oneliner simulating it with the date faked to 2010-10-31: $ perl5.12.0 -MTime::Fake=1288545834 -MAstro::Sunrise -le 'print join(" - ", sun_set(13.5,52.5))' 17:39 The correct value should be probably 16:39. I think the problem lies in how the DST value in sun_set is calculated. The function uses DateTime->today->set_time_zone( 'local' ); today uses the beginning of the date, that is, 00:00:00. But at this time DST was still in effect, so the offset was +2. Sunset however happened when DST was not anymore in effect. I am not sure how to fix this correctly. As a workaround it would be better to use today and set the time to something like midday, e.g. my $today = DateTime->today->set_time_zone( 'local' ); $today->set( hour => 12 ); # new line $today->add( days => $offset ); (I can create a format patch if this change is accepted) Regards, Slaven
On 2010-10-31 13:33:43, SREZIC wrote: Show quoted text
> Today I got a wrong result for the sun_set time in Berlin. Here's a > oneliner simulating it with the date faked to 2010-10-31: > > $ perl5.12.0 -MTime::Fake=1288545834 -MAstro::Sunrise -le 'print join(" > - ", sun_set(13.5,52.5))' > 17:39 > > The correct value should be probably 16:39. I think the problem lies in > how the DST value in sun_set is calculated. The function uses > > DateTime->today->set_time_zone( 'local' ); > > today uses the beginning of the date, that is, 00:00:00. But at this > time DST was still in effect, so the offset was +2. Sunset however > happened when DST was not anymore in effect. > > I am not sure how to fix this correctly. As a workaround it would be > better to use today and set the time to something like midday, e.g. > > my $today = DateTime->today->set_time_zone( 'local' ); > $today->set( hour => 12 ); # new line > $today->add( days => $offset ); > > (I can create a format patch if this change is accepted) >
A formal patch can be found here: https://cpan.metacpan.org/authors/id/S/SR/SREZIC/patches/Astro-Sunrise-0.91-SREZIC-01.patch Regards, Slaven
Le Dim 15 Fév 2015 21:10:55, SREZIC a écrit : [cut] Show quoted text
> > A formal patch can be found here: > https://cpan.metacpan.org/authors/id/S/SR/SREZIC/patches/Astro- > Sunrise-0.91-SREZIC-01.patch > > Regards, > Slaven
Thanks, applied to https://github.com/jforget/Astro-Sunrise Yet, there are other issues I want to fix before releasing a new version of the module to CPAN. See the resolved issues for DateTime::Event::Sunrise, especially: https://rt.cpan.org/Ticket/Display.html?id=91783