Skip Menu |

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

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

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

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



Hi Steven, DateTime::Format::Natural does not handle the format yyyy-mm-dd well at all. perl -MDateTime::Format::Natural -le '$parser = DateTime::Format::Natural->new(); print $parser->parse_datetime("2007- 01-01")' Use of uninitialized value in numeric gt (>) at /opt/local/lib/perl5/ site_perl/5.8.8/DateTime/Format/Natural.pm line 100. Use of uninitialized value in length at /opt/local/lib/perl5/site_perl/ 5.8.8/DateTime/Format/Natural.pm line 103. The 'year' parameter (undef) to DateTime::set was an 'undef', which is not one of the allowed types: scalar at /opt/local/lib/perl5/site_perl/5.8.8/darwin-2level/DateTime.pm line 1560 DateTime::set('undef', 'year', 'undef') called at /opt/local/ lib/perl5/site_perl/5.8.8/darwin-2level/DateTime.pm line 1574 DateTime::set_year('DateTime=HASH(0x180f840)', 'undef') called at /opt/local/lib/perl5/site_perl/5.8.8/DateTime/Format/Natural.pm line 105 DateTime::Format::Natural::parse_datetime('DateTime::Format::Natural=HASH(0x1800568)', '2007-01-01') called at -e line 1 Would be great if you could fix! Thanks :) Shawn
From: SCHUBIGER [...] cpan.org
On Fri Sep 07 17:55:46 2007, SARTAK wrote: Show quoted text
> DateTime::Format::Natural does not handle the format yyyy-mm-dd well > at all.
It does. Show quoted text
> perl -MDateTime::Format::Natural -le '$parser = > DateTime::Format::Natural->new(); print $parser->parse_datetime("2007- > 01-01")'
You're not passing a format to the parameter 'format' within the constructor. Try `DateTime::Format::Natural->new(format => 'yyyy-mm-dd')` instead. And if you want to test dates, use DateTime::Format::Natural's 'dateparse'.
Subject: Handling yyyy-mm-dd
On Sat Sep 08 10:31:55 2007, SCHUBIGER wrote: Show quoted text
> On Fri Sep 07 17:55:46 2007, SARTAK wrote:
> > DateTime::Format::Natural does not handle the format yyyy-mm-dd well > > at all.
> > It does. >
> > perl -MDateTime::Format::Natural -le '$parser = > > DateTime::Format::Natural->new(); print $parser-
>parse_datetime("2007-
> > 01-01")'
> > You're not passing a format to the parameter 'format' within the > constructor. Try `DateTime::Format::Natural->new(format => > 'yyyy-mm-dd')` instead. And if you want to test dates, use > DateTime::Format::Natural's 'dateparse'.
I'd argue that yyyy-mm-dd is unambiguous (the only clash it could have is with yyyy-dd-mm, and I have never seen such a beast) and should always be handled. It shouldn't be throwing an error, at least. :/ Shawn
On Sat Sep 08 16:32:54 2007, SARTAK wrote: Show quoted text
> I'd argue that yyyy-mm-dd is unambiguous (the only clash it could have > is with yyyy-dd-mm, and I have never seen such a beast) and should > always be handled.
Well, I'm inclined to think that it'd require 1. looking out for either '-', '.' or '/' (currently done) 2.1 if we have a chunk with length 4 at the front assume month/day follows 2.2 if we have a chunk with length 4 at the end assume day/month preceeds 2.3 split accordingly 3. else go by the 'format' parameter
Resolved as of v0.39.