Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: JEB [...] cpan.org
Cc:
AdminCc:

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



Subject: Leading 0 on day-of-month with ordinal indicator
Hello, the following date appears to not parse: February 01st, 2011 7:02 pm EST Using the code: UnixDate( ParseDateString( "February 01st, 2011 7:02 pm EST" ), "%s" ); Dropping the leading zero from the day of the month (01 -> 1) seems to fix this, as does dropping the Ordinal Indicator "st" (01st -> 01), but thats not an option to me (source documents are out of my control). Of course, this is only a problem between the 1st and the 9th of the month!! :) I'm using the version 5 of the module, and have tested in Debian almost-stable module version 6.11, and Centos very-old 5.44, and both fail in the same way. Many thanks, James
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.