Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: Vitaly.Shupak [...] deshaw.com
Cc:
AdminCc:

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



Subject: invalid dates accepted as valid
Date: Thu, 2 Jul 2015 16:20:32 +0000
To: "'bug-Date-Manip [...] rt.cpan.org'" <bug-Date-Manip [...] rt.cpan.org>
From: "Shupak, Vitaly" <Vitaly.Shupak [...] deshaw.com>
The latest version of Date::Manip (at least since 6.41) accepts dates that are not valid: 6.41, 6.50 $ perl -MDate::Manip -le '$m=UnixDate("20141301","%Y%m%d %H:%M:%S") or die("Invalid date\n");print $m;' 20160220 14:05:06 6.24 $ perl -MDate::Manip -le '$m=UnixDate("20141301","%Y%m%d %H:%M:%S") or die("Invalid date\n");print $m;' Invalid date Is this a bug? Thanks, Vitaly
It was a bug... but not in the way you are thinking. One of the formats tried when parsing a date is to treat it as a delta (i.e. 'in 2 days'). Unfortunately, a pure number (such as 20141301) is treated as a valid delta (equivalent to 'in 20141301 seconds'). So that's the date that is being parsed. There was a bug in the earlier version that wasn't correctly treating that as a delta that has since been fixed. If you were to use the Object Oriented functions, you could eliminate this problem: $obj = new Date::Manip::Date; $obj->parse("20141301","nodelta"); but the functional interface doesn't have that flexibility. However, in looking at it, it is very easy to add, so I've added the same functionality to ParseDate and ParseDateString, so you'll be able to go: ParseDate('20141301','nodelta') and get the result you're looking for. This will be in the next release.