Skip Menu |

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

Report information
The Basics
Id: 113007
Status: resolved
Priority: 0/
Queue: Date-Manip

People
Owner: Nobody in particular
Requestors: dyker [...] agava.com
Cc:
AdminCc:

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



Subject: ParseDate returns false for some correct dates
Date: Mon, 14 Mar 2016 18:20:45 +0300
To: bug-Date-Manip [...] rt.cpan.org
From: Pronichev Alexander <dyker [...] agava.com>
ParseDate returns false for some correct dates. For example: 1916-07-03 1930-06-21 1981-04-01 1982-04-01 1983-04-01 1984-04-01 dyker@dyker:~$ perl -v This is perl 5, version 20, subversion 2 (v5.20.2) built for x86_64-linux-gnu-thread-multi (with 42 registered patches, see perl -V for more detail) dyker@dyker:~$ perl -MDate::Manip -e 'warn Date::Manip->VERSION' 6.53 at -e line 1. here is a script, how i found it: #!/bin/perl use strict; use warnings; use Date::Manip qw(ParseDate); use POSIX qw(strftime); my $now = time(); my $start = $now - 86400*365*100; while ( $start < $now ) { my $date = strftime("%Y-%m-%d", localtime($start)); print $date."\n" if !ParseDate( $date ); $start += 86400; }
You never specified what timezone you are in, so I can't reproduce this precisely... but you're running into a daylight saving time issue. First, a minor problem with your script is that you're treating a day as exactly 24 hours long (NOT true twice a year... one day is 23 hours long and one is 25 hours long due to daylight saving time). So $start actually refers to a date Y-M-D 01:00:00 some of the year and Y-M-D 00:00:00 the rest of the year. Since you're discarding h/m/s by only working with y/m/d, portion of the date, you're managing to work around it, but your script will behave differently if you ran it during a DST portion of the year as opposed to a non-DST portion. But back to the result you are seeing... Date::Manip works with FULL dates, so you're basically referring to a date Y-M-D 00:00:00 . In a few timezones, during the spring daylight saving time transition, it happens at midnight and so that date does not exist, and so ParseDate is correctly returning nothing. Without knowing what timezone you are in, I'll bet you are in one where time changes occurred at midnight on on those dates. I'm surprised about the June and July changes though... what timezone ARE you in? In any case, I ran your script in my timezone (America/New York) which has no midnight transitions, and your script ran without producing any output (meaning that the dates all exist in my timezone). Hope that helps. You'll need to decide what you
Subject: Re: [rt.cpan.org #113007] AutoReply: ParseDate returns false for some correct dates
Date: Tue, 15 Mar 2016 12:42:25 +0300
To: bug-Date-Manip [...] rt.cpan.org
From: Pronichev Alexander <dyker [...] agava.com>
Thanks for such detailed answer. Yes I ran this script in MSK (Europe/Moscow) timezone. We have a long story of daylight saving time and it's finally was cancelled in 2011 as i know. On 14.03.2016 18:21, Bugs in Date-Manip via RT wrote: Show quoted text
> Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "ParseDate returns false for some correct dates", > a summary of which appears below. > > There is no need to reply to this message right now. Your ticket has been > assigned an ID of [rt.cpan.org #113007]. Your ticket is accessible > on the web at: > > https://rt.cpan.org/Ticket/Display.html?id=113007 > > Please include the string: > > [rt.cpan.org #113007] > > in the subject line of all future correspondence about this issue. To do so, > you may reply to this message. > > Thank you, > bug-Date-Manip@rt.cpan.org > > ------------------------------------------------------------------------- > ParseDate returns false for some correct dates. For example: > > 1916-07-03 > 1930-06-21 > 1981-04-01 > 1982-04-01 > 1983-04-01 > 1984-04-01 > > > dyker@dyker:~$ perl -v > > This is perl 5, version 20, subversion 2 (v5.20.2) built for > x86_64-linux-gnu-thread-multi > (with 42 registered patches, see perl -V for more detail) > > dyker@dyker:~$ perl -MDate::Manip -e 'warn Date::Manip->VERSION' > 6.53 at -e line 1. > > > here is a script, how i found it: > #!/bin/perl > > use strict; > use warnings; > > use Date::Manip qw(ParseDate); > use POSIX qw(strftime); > > my $now = time(); > my $start = $now - 86400*365*100; > > while ( $start < $now ) > { > my $date = strftime("%Y-%m-%d", localtime($start)); > print $date."\n" if !ParseDate( $date ); > $start += 86400; > } > >