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