Skip Menu |

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

Report information
The Basics
Id: 56955
Status: resolved
Priority: 0/
Queue: DateTime-Format-Natural

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

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



Subject: 12:XX PM does not work
# This doesn't work for me: use DateTime::Format::Natural; my $df = DateTime::Format::Natural->new; my $dt = $df->parse_datetime('12:14 PM'); warn $dt->hms; # outputs the current time rather than 12:14:00 # But this does: my $dt2 = $df->parse_datetime('1:14 PM'); warn $dt2->hms; # outputs the 13:14:00 I want to track this down, but I'm in a hurry in the moment. If I can track it down, I will add to the report later, hopefully with a patch. Cheers.
Subject: 12:XX AM or PM does not work
I found the issue. The way Natural parses AM/PM is wrong. It currently treats AM as +0 hours and PM as +12 hours. This is not correct. A.M. is ante meridiem (before noon) and P.M. is post meridiem (after noon). Therefore, 12:14am is 0014 and 12:14pm is 1214. Technically, noon is not after noon, but 12:00 PM is noon since 12:00 AM is midnight. I don't know where it would be best to insert this exception to keep the abstractions of Natural in place, or I would submit a patch. I can suggest two new test cases in t/01-parse.t to the @simple tests: { '12:14 PM' => '24.11.2006 12:14:00' }, { '12:14 AM' => '24.11.2006 00:14:00' }, If I add that, all the tests run for those two fail.
Fixed in v0.87. Thanks!