Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: zinser [...] zinser.no-ip.info
Cc:
AdminCc:

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



Subject: Ordinal dates with leading zero not parsed
Hello, this has been found and verified with Perl 5.12.1 on Linux and Perl 5.12.3 on OpenVMS. In the following test code parsing will fail silently for the last string: use Date::Manip; $tstr = "Mar, 9,2011 17:12:00"; my $base_time = ParseDate($tstr); print "String: ", $tstr, " Base: ", $base_time, "\n"; $tstr = "Mar, 9th,2011 17:12:00"; my $base_time = ParseDate($tstr); print "String: ", $tstr, " Base: ", $base_time, "\n"; $tstr = "Mar, 09,2011 17:12:00"; my $base_time = ParseDate($tstr); print "String: ", $tstr, " Base: ", $base_time, "\n"; $tstr = "Mar, 09th,2011 17:12:00"; my $base_time = ParseDate($tstr); print "String: ", $tstr, " Base: ", $base_time, "\n"; Result: String: Mar, 9,2011 17:12:00 Base: 2011030917:12:00 String: Mar, 9th,2011 17:12:00 Base: 2011030917:12:00 String: Mar, 09,2011 17:12:00 Base: 2011030917:12:00 String: Mar, 09th,2011 17:12:00 Base: If would be nice if ordinal with leading Zeros would be parsed correctly too. All the best, Martin
The problem is that parsing '1st', '2nd', etc. isn't parsing a number. It's parsing a string which can then be translated to a number. The regular expression ends up being of the form: (1st|2nd|3rd|...) In order to parse a string of the form you suggest, I'd have to make the regular expression: (1st|01st|2nd|...) Since '01st' is NOT a common way of expressing this, I'm not convinced that the overhead is worthwhile. A preferable solution would be for you to do something like: $date = "February 01st ..."; $date =~ s/(January|February|...) 0/\1 /; and then pass that to ParseDateString. An alternate way would be to use a new version (6.00+) of Date::Manip and use the parse_format method to construct a simple regular expression to parse it. Either way is fine.