Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: colm.dougan [...] gmail.com
Cc:
AdminCc:

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



Subject: Patch to add day_month_year_at
Hi, This patch adds support for day / month / year / time which was previously not accepted, e.g. : 22nd May 2011 at 21:35 (as distinct from May 22nd 2011 at 21:35 which was previously accepted). There is a further issue which my patch doesn't address. When I do : my @extracted = $parser->extract_datetime("22nd May 2011 at 21:35"); I get back a list of 2 items when I would like it to be a list of 1 item so that I can pass that one item to parse_datetime and get back a date and a time. The 'at' seems to make it ambiguous. I think it would nice if *any* time could be optionally preceded by an "at" without us having to list all the possible combinations (without and without "at") of it in the per language file. Thanks. Colm
Subject: day_month_year_at.diff
diff -Brub ../DateTime-Format-Natural-0.94_02_orig//lib/DateTime/Format/Natural/Lang/EN.pm ./lib/DateTime/Format/Natural/Lang/EN.pm --- ../DateTime-Format-Natural-0.94_02_orig//lib/DateTime/Format/Natural/Lang/EN.pm 2011-04-14 15:32:09.000000000 +0100 +++ ./lib/DateTime/Format/Natural/Lang/EN.pm 2011-04-26 23:45:50.942731837 +0100 @@ -1728,6 +1728,61 @@ { truncate_to => [qw(hour minute)] }, ], ], + day_month_year_at => [ + [ 'REGEXP', 'REGEXP', 'REGEXP', 'REGEXP' ], + [ + { 0 => $RE{monthday}, 1 => $RE{month}, 2 => $RE{year}, 3 => $RE{time} }, + [ [ 0 ] ], + [ $extended_checks{ordinal} ], + [ + [ + 0, + { 1 => [ $flag{month_name}, $flag{month_num} ] }, + ], + [ 2 ], + [ 3 ], + ], + [ {}, { unit => 'year' }, {} ], + [ '_month_day', '_unit_date', '_time' ], + { truncate_to => [qw(hour minute)] }, + ], + [ + { 0 => $RE{monthday}, 1 => $RE{month}, 2 => $RE{year}, 3 => $RE{time_am} }, + [ [ 0 ], [ 3 ] ], + [ $extended_checks{ordinal}, $extended_checks{meridiem} ], + [ + [ + 0, + { 1 => [ $flag{month_name}, $flag{month_num} ] }, + ], + [ 2 ], + [ + { 3 => [ $flag{time_am} ] }, + ], + ], + [ {}, { unit => 'year' }, {} ], + [ '_month_day', '_unit_date', '_at' ], + { truncate_to => [qw(hour minute)] }, + ], + [ + { 0 => $RE{monthday}, 1 => $RE{month}, 2 => $RE{year}, 3 => $RE{time_pm} }, + [ [ 0 ], [ 3 ] ], + [ $extended_checks{ordinal}, $extended_checks{meridiem} ], + [ + [ + 0, + { 1 => [ $flag{month_name}, $flag{month_num} ] }, + ], + [ 2 ], + [ + { 3 => [ $flag{time_pm} ] }, + ], + ], + [ {}, { unit => 'year' }, {} ], + [ '_month_day', '_unit_date', '_at' ], + { truncate_to => [qw(hour minute)] }, + ], + ], at_month_day => [ [ 'REGEXP', 'REGEXP', 'REGEXP' ], [ diff -Brub ../DateTime-Format-Natural-0.94_02_orig//t/01-parse.t ./t/01-parse.t --- ../DateTime-Format-Natural-0.94_02_orig//t/01-parse.t 2011-04-14 15:32:09.000000000 +0100 +++ ./t/01-parse.t 2011-04-26 23:53:22.312732361 +0100 @@ -275,12 +275,14 @@ { 'january 11' => '11.01.2006 00:00:00' }, { '11 january' => '11.01.2006 00:00:00' }, { '18 oct 17:00{sec}' => '18.10.2006 17:00:{sec}' }, + { '18 oct 2001 17:00{sec}' => '18.10.2001 17:00:{sec}' }, { '18 oct 5{min_sec}am' => '18.10.2006 05:{min_sec}' }, { '18 oct 5{min_sec}pm' => '18.10.2006 17:{min_sec}' }, { '18 oct 5{min_sec} am' => '18.10.2006 05:{min_sec}' }, { '18 oct 5{min_sec} pm' => '18.10.2006 17:{min_sec}' }, { 'dec 25' => '25.12.2006 00:00:00' }, { 'feb 28 3:00{sec}' => '28.02.2006 03:00:{sec}' }, + { 'feb 28 2001 3:00{sec}' => '28.02.2001 03:00:{sec}' }, { 'feb 28 3{min_sec}am' => '28.02.2006 03:{min_sec}' }, { 'feb 28 3{min_sec}pm' => '28.02.2006 15:{min_sec}' }, { 'feb 28 3{min_sec} am' => '28.02.2006 03:{min_sec}' }, @@ -299,7 +301,11 @@ { 'October 2006' => '01.10.2006 00:00:00' }, { 'february 14, 2004' => '14.02.2004 00:00:00' }, { 'jan 3 2010' => '03.01.2010 00:00:00' }, + { 'jan 3 2010 17:23' => '03.01.2010 17:23:00' }, + { 'jan 3 2010 5{min_sec}pm' => '03.01.2010 17:{min_sec}' }, { '3 jan 2000' => '03.01.2000 00:00:00' }, + { '3 jan 2000 03:02' => '03.01.2000 03:02:00' }, + { '3 jan 2000 3{min_sec}am' => '03.01.2000 03:{min_sec}' }, { '2010 october 28' => '28.10.2010 00:00:00' }, { '27/5/1979' => '27.05.1979 00:00:00' }, { '6' => '24.11.2006 06:00:00' }, @@ -310,7 +316,7 @@ { '+2d' => '26.11.2006 01:13:08' }, ); -_run_tests(464, [ [ \@simple ], [ \@complex ], [ \@specific ] ], \&compare); +_run_tests(476, [ [ \@simple ], [ \@complex ], [ \@specific ] ], \&compare); sub compare {
On Tue Apr 26 19:20:48 2011, colm.dougan@gmail.com wrote: Show quoted text
> This patch adds support for day / month / year / time which was > previously not accepted, e.g. : > > 22nd May 2011 at 21:35 > > (as distinct from May 22nd 2011 at 21:35 which was previously accepted).
Added with required precision of ambiguous time adjusted. Show quoted text
> When I do : > > my @extracted = $parser->extract_datetime("22nd May 2011 at 21:35"); > > I get back a list of 2 items when I would like it to be a list of 1 item > so that I can pass that one item to parse_datetime and get back a date > and a time. The 'at' seems to make it ambiguous. I think it would nice > if *any* time could be optionally preceded by an "at" without us having > to list all the possible combinations (without and without "at") of it > in the per language file.
Done in v0.94_04.