Skip Menu |

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

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

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

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



Subject: "Jan 10" inconsistent with "January 10"
Hi Stevan, Yet another prefer_future weirdness. Collect them all! my $dtfn = DateTime::Format::Natural->new(prefer_future => 1); warn $dtfn->parse_datetime("10 Jan")->ymd; # 2007-01-10 (wrong) warn $dtfn->parse_datetime("10 January")->ymd; # 2008-01-10 (right) I've looked at the code and it certainly looks like these should be using the same codepath. But they're obviously not. In other news, you have the following code in Lang::EN: %data_months = map { $_ => $i++ } qw(January February March April May June July August September October November December); %data_months_abbrev = map { substr($_, 0, 3) => $_ } keys %data_months; my $months_re = join '|', keys %data_months; my @abbrev = keys %data_months; $_ = substr($_, 0, 3) foreach @abbrev; $months_re .= '|' . join '|', @abbrev; $RE{month} = qr/^($months_re)$/i; which is doing the same thing (abbreviating month names) twice. You do the same with weekday names. The second paragraph should probably become just: my $months_re = join '|', keys(%data_months), keys(%data_months_abbrev); $RE{month} = qr/^($months_re)$/i; Or (of course) kill the %data_months_abbrev variable and do the abbreviation with an array. Thanks! Shawn
On Wed Dec 05 22:56:42 2007, SARTAK wrote: Show quoted text
> my $dtfn = DateTime::Format::Natural->new(prefer_future => 1); > warn $dtfn->parse_datetime("10 Jan")->ymd; # 2007-01-10 (wrong) > warn $dtfn->parse_datetime("10 January")->ymd; # 2008-01-10 (right) > > I've looked at the code and it certainly looks like these should be > using the same codepath. But they're obviously not.
They do (see the method trace() or --trace/-t within dateparse). Show quoted text
> In other news, you have the following code in Lang::EN: > > %data_months = map { > $_ => $i++ > } qw(January February March April May June July August September > October November December); > %data_months_abbrev = map { > substr($_, 0, 3) => $_ > } keys %data_months; > > my $months_re = join '|', keys %data_months; > my @abbrev = keys %data_months; > $_ = substr($_, 0, 3) foreach @abbrev; > $months_re .= '|' . join '|', @abbrev; > $RE{month} = qr/^($months_re)$/i; > > which is doing the same thing (abbreviating month names) twice. You do > the same with weekday names. The second paragraph should probably > become just: > > my $months_re = join '|', keys(%data_months), > keys(%data_months_abbrev); > $RE{month} = qr/^($months_re)$/i;
Yes, I agree; but did you notice that %RE is not being accessed from the outside, even though possible? Show quoted text
> Or (of course) kill the %data_months_abbrev variable and do the > abbreviation with an array.
I've merged the two hashes (non-abbrev & abbrev) into one, because I think, we might someday use it. BTW, the cause of the misbehaviour was _post_process_options() only operating on non-abbreviated week-/monthnames.
Resolved as of v0.62.