Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime-Format-Strptime CPAN distribution.

Report information
The Basics
Id: 7502
Status: resolved
Priority: 0/
Queue: DateTime-Format-Strptime

People
Owner: rickm [...] cpan.org
Requestors: dfaraldo [...] redhat.com
Cc:
AdminCc:

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



To: bug-datetime-format-strptime [...] rt.cpan.org
Subject: Minor bug in DateTime::Format::Strptime v1.05
From: "Dave Faraldo" <dfaraldo [...] redhat.com>
Date: Fri, 27 Aug 2004 18:31:21 -0700
Download (untitled) / with headers
text/plain 1.5k
Hey there, Rick (or whoever reads the bug reports :). I'm evangalizing the use of the DateTime modules here at Red Hat, and wanted to do a demonstration of how easily they handle time zones by showing edge cases. But I got an error when I tried to parse the following date in the 'Asia/Manila' time zone: epoch => 259344000, str => 'Wed Mar 22 01:00:00 1978', (This is the last time Manila switched to DST.) The parse_datetime function died with: Invalid local time for date in time zone: Asia/Manila Eh??? I did a little poking, and found the problem. Around line 443, you do some validation on the day of the month: if ($Day) { $self->local_croak("There is no use providing a day without providing a month and year.") and return undef unless $Year and $Month; my $dt = DateTime->new(year=>$Year, month=>$Month, day=>$Day, time_zone => $use_timezone); $self->local_croak("There is no day $Day in $dt->month_name, $Year") and return undef unless $dt->month == $Month; } That DateTime->new() call, which assumes midnight on the specified day/month/year, works for most days in most places ... but on March 22, 1978 in Manila, there *was* no midnight -- the local time jumped from 11:59PM standard to 1AM DST! :) I believe the following fixes the problem: my $dt = DateTime->new(year=>$Year, month=>$Month, day=>$Day, hour=>12, time_zone => $use_timezone); As far as I know, nobody does DST switchovers in the middle of the day. Attached are a patch and a sample script. Thanks! -=< Dave >=-
Download (untitled) / with headers
text/plain 981b
*** /usr/lib/perl5/site_perl/5.8.3/DateTime/Format/Strptime.pm Wed Aug 18 00:32:50 2004 --- DateTime/Format/Strptime.pm Fri Aug 27 18:27:40 2004 *************** *** 440,446 **** : ''; if ($Day) { $self->local_croak("There is no use providing a day without providing a month and year.") and return undef unless $Year and $Month; ! my $dt = DateTime->new(year=>$Year, month=>$Month, day=>$Day, time_zone => $use_timezone); $self->local_croak("There is no day $Day in $dt->month_name, $Year") and return undef unless $dt->month == $Month; } --- 440,446 ---- : ''; if ($Day) { $self->local_croak("There is no use providing a day without providing a month and year.") and return undef unless $Year and $Month; ! my $dt = DateTime->new(year=>$Year, month=>$Month, day=>$Day, hour=>12, time_zone => $use_timezone); $self->local_croak("There is no day $Day in $dt->month_name, $Year") and return undef unless $dt->month == $Month; }
Download (untitled) / with headers
text/plain 483b
#!/usr/bin/perl use strict; use warnings; no warnings 'uninitialized'; use DateTime::Format::Strptime; use POSIX qw(tzset); my $FORMAT = '%a %b %e %T %Y'; my $ZONE = 'Asia/Manila'; my $formatter = DateTime::Format::Strptime->new( pattern => $FORMAT, time_zone => $ZONE, ); # The last time Manila switched to DST (actual) my $rec = { epoch => 259344000, str => 'Wed Mar 22 01:00:00 1978', }; my $dt = $formatter->parse_datetime($rec->{'str'});
To: Rick Measham <rickm [...] isite.net.au>
CC: bug-datetime-format-strptime [...] rt.cpan.org
Subject: Re: [cpan #7502] Minor bug in DateTime::Format::Strptime v1.05
From: "Dave Faraldo" <dfaraldo [...] redhat.com>
Date: Mon, 30 Aug 2004 16:29:05 -0700
RT-Send-Cc:
Download (untitled) / with headers
text/plain 3.6k
Thanks for the quick fix! Makes me reluctant to hit you with another one, but ... When I tried to install 1.06 today, the locales test bombed with an invalid day. The problem: foreach my $month (1..12) { my $dt = DateTime->now( locale => $locale )->set( month => $month ); Unfortunately, I'm running the test on 8/30, and February doesn't have a 30th day, so set(month => 2) fails. :-P I changed it to: foreach my $month (1..12) { my $dt = DateTime->now( locale => $locale )->set( month => $month , day => 1); since every month has a day 1. (I did the same with t/more/001_all_locales.t.) Thanks again! -=< Dave >=- P.S. Yeah, Dave R. kicks ass. :) Original message follows: ------------------------- Show quoted text
> Date: Sat, 28 Aug 2004 15:41:16 +1000 > From: Rick Measham <rickm@isite.net.au> > Subject: Re: [cpan #7502] Minor bug in DateTime::Format::Strptime v1.05
Show quoted text
> Thanks for the bug report and for evangelizing DT at RH. Dave (the > project leader) has done a great job with the core parts of DT. > > I've fixed the issed and release this as 1.06. > > Cheers! > Rick >
> >This message about DateTime-Format-Strptime was sent to you by > >dfaraldo@redhat.com <dfaraldo@redhat.com> via rt.cpan.org > > > >Full context and any attached attachments can be found at: > ><URL: https://rt.cpan.org/Ticket/Display.html?id=7502 > > > > >Hey there, Rick (or whoever reads the bug reports :). > > > >I'm evangalizing the use of the DateTime modules here at Red Hat, > >and wanted to do a demonstration of how easily they handle time > >zones by showing edge cases. But I got an error when I tried > >to parse the following date in the 'Asia/Manila' time zone: > > > > epoch => 259344000, > > str => 'Wed Mar 22 01:00:00 1978', > > > >(This is the last time Manila switched to DST.) > > > >The parse_datetime function died with: > > > > Invalid local time for date in time zone: Asia/Manila > > > >Eh??? I did a little poking, and found the problem. Around > >line 443, you do some validation on the day of the month: > > > > if ($Day) { > > $self->local_croak("There is no use providing a day > >without providing a month and year.") and return undef unless $Year > >and $Month; > > my $dt = DateTime->new(year=>$Year, month=>$Month, > >day=>$Day, time_zone => $use_timezone); > > $self->local_croak("There is no day $Day in > >$dt->month_name, $Year") and return undef > > unless $dt->month == $Month; > > } > > > >That DateTime->new() call, which assumes midnight on the specified > >day/month/year, works for most days in most places ... but on March 22, > >1978 in Manila, there *was* no midnight -- the local time jumped > >from 11:59PM standard to 1AM DST! :) > > > >I believe the following fixes the problem: > > > > my $dt = DateTime->new(year=>$Year, month=>$Month, day=>$Day, > >hour=>12, time_zone => $use_timezone); > > > >As far as I know, nobody does DST switchovers in the middle of the day. > > > >Attached are a patch and a sample script. Thanks! > > > > -=< Dave >=-
> > > -- > -------------------------------------------------------- > There are 10 kinds of people: > those that understand binary, and those that don't. > -------------------------------------------------------- > The day Microsoft makes something that doesn't suck > is the day they start selling vacuum cleaners > -------------------------------------------------------- > "Write a wise proverb and your name will live forever." > -- Anonymous > -------------------------------------------------------- >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.