Skip Menu |

This queue is for tickets about the Panda-Date CPAN distribution.

Report information
The Basics
Id: 96529
Status: resolved
Priority: 0/
Queue: Panda-Date

People
Owner: Nobody in particular
Requestors: sergle.ua [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Date arithmetics and DST
Date: Wed, 18 Jun 2014 14:42:17 +0300
To: bug-Panda-Date [...] rt.cpan.org
From: Sergey Leschenko <sergle.ua [...] gmail.com>
​Hi,​ Issue observed: subtracting interval from date produces incorrect result if crossing DST change. use strict; use warnings; use Panda::Date; sub p { my $pdate = shift; printf "%s tz:%s dst:%s epoch:%s\n", $pdate->string, $pdate->tz->{name}, $pdate->isdst ? 'Y' : 'N', $pdate->epoch; }; #-- dst starts at 01:00 my $date = Panda::Date->new('2014-03-30 00:59:59'); $date->tz('Europe/London'); p($date); my $delta = Panda::Date::Rel->new({sec => 1}); $date->add($delta); p($date); $date->subtract($delta); p($date); output: 2014-03-30 00:59:59 tz:Europe/London dst:N epoch:1396141199 2014-03-30 02:00:00 tz:Europe/London dst:Y epoch:1396141200 2014-03-30 02:59:59 tz:Europe/London dst:Y epoch:1396144799 I would expect value '2014-03-30 00:59:59' as a last result. -- Sergey
Срд Июн 18 07:42:49 2014, smrage писал: Show quoted text
> ​Hi,​ > > > Issue observed: subtracting interval from date produces incorrect result if > crossing DST change. > > use strict; > use warnings; > use Panda::Date; > > sub p { > my $pdate = shift; > printf "%s tz:%s dst:%s epoch:%s\n", > $pdate->string, $pdate->tz->{name}, $pdate->isdst ? 'Y' : 'N', > $pdate->epoch; > }; > > #-- dst starts at 01:00 > my $date = Panda::Date->new('2014-03-30 00:59:59'); > $date->tz('Europe/London'); > p($date); > my $delta = Panda::Date::Rel->new({sec => 1}); > $date->add($delta); > p($date); > $date->subtract($delta); > p($date); > > output: > 2014-03-30 00:59:59 tz:Europe/London dst:N epoch:1396141199 > 2014-03-30 02:00:00 tz:Europe/London dst:Y epoch:1396141200 > 2014-03-30 02:59:59 tz:Europe/London dst:Y epoch:1396144799 > > I would expect value '2014-03-30 00:59:59' as a last result. >
Sorry, i've not been checking rt.cpan.org for a while :( This bug won't appear in new Panda::Date release which is comming in a week or two. Thanks
Was fixed a long time ago