r64481 - in /trunk/libdatetime-format-natural-perl: Changes META.yml README debian/changelog lib/DateTime/Format/Natural.pm lib/DateTime/Format/Natural/Lang/EN.pm lib/DateTime/Format/Natural/Utils.pm t/01-parse.t t/10-parse_failure.t t/14-trace.t

angelabad-guest at users.alioth.debian.org angelabad-guest at users.alioth.debian.org
Tue Nov 2 14:09:18 UTC 2010


Author: angelabad-guest
Date: Tue Nov  2 14:09:03 2010
New Revision: 64481

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=64481
Log:
New upstream release

Modified:
    trunk/libdatetime-format-natural-perl/Changes
    trunk/libdatetime-format-natural-perl/META.yml
    trunk/libdatetime-format-natural-perl/README
    trunk/libdatetime-format-natural-perl/debian/changelog
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Utils.pm
    trunk/libdatetime-format-natural-perl/t/01-parse.t
    trunk/libdatetime-format-natural-perl/t/10-parse_failure.t
    trunk/libdatetime-format-natural-perl/t/14-trace.t

Modified: trunk/libdatetime-format-natural-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/Changes?rev=64481&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/Changes (original)
+++ trunk/libdatetime-format-natural-perl/Changes Tue Nov  2 14:09:03 2010
@@ -1,4 +1,50 @@
 Revision history for Perl extension DateTime::Format::Natural.
+
+0.91  2010-11-01  <schubiger at cpan.org>
+
+ - Merged development version to stable.
+
+0.90_04  2010-10-30  <schubiger at cpan.org>
+
+ - New supported formats: <time> <month> <monthday> and
+   <time> AM/PM <month> <monthday>. [rt #62164 - Vladimir Marek]
+
+ - Add support for the <time am/pm> <month> <monthday> format.
+
+ - Test and document the new formats.
+
+0.90_03  2010-10-28  <schubiger at cpan.org>
+
+ - New supported formats: <monthday> <month> <time>,
+   <monthday> <month> <time> AM/PM and <month> <monthday>
+   <time> AM/PM. [rt #62164 - Vladimir Marek]
+
+ - Add support for the <monthday> <month> <time am/pm> format.
+
+ - Test and document the new formats.
+
+0.90_02  2010-10-22  <schubiger at cpan.org>
+
+ - New supported formats: <variant> <weekday> <time> AM/PM and
+   <time> AM/PM <variant> <weekday>. [rt #62164 - Vladimir Marek]
+
+ - Add support for the <variant> <weekday> <time am/pm> format.
+
+ - Test and document the new formats.
+
+ - Record the grammar keyword for each valid expression parsed.
+
+ - Describe trace()'s purpose and its inclusion of a grammar keyword.
+
+ - Insert expected grammar keywords in 14-trace.t.
+
+0.90_01  2010-10-13  <schubiger at cpan.org>
+
+ - Fix reference to the Calc class in the documentation of trace().
+
+ - Adjust phrasing of parse_datetime_duration()'s documentation.
+
+ - Correct spelling of the examples description.
 
 0.90  2010-10-04  <schubiger at cpan.org>
 

Modified: trunk/libdatetime-format-natural-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/META.yml?rev=64481&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/META.yml (original)
+++ trunk/libdatetime-format-natural-perl/META.yml Tue Nov  2 14:09:03 2010
@@ -1,6 +1,6 @@
 ---
 name: DateTime-Format-Natural
-version: 0.90
+version: 0.91
 author:
   - 'Steven Schubiger <schubiger at cpan.org>'
 abstract: Create machine readable date/time with natural parsing logic
@@ -30,7 +30,7 @@
 provides:
   DateTime::Format::Natural:
     file: lib/DateTime/Format/Natural.pm
-    version: 0.90
+    version: 0.91
   DateTime::Format::Natural::Aliases:
     file: lib/DateTime/Format/Natural/Aliases.pm
     version: 0.03
@@ -54,13 +54,13 @@
     version: 1.06
   DateTime::Format::Natural::Lang::EN:
     file: lib/DateTime/Format/Natural/Lang/EN.pm
-    version: 1.38
+    version: 1.41
   DateTime::Format::Natural::Test:
     file: lib/DateTime/Format/Natural/Test.pm
     version: 0.05
   DateTime::Format::Natural::Utils:
     file: lib/DateTime/Format/Natural/Utils.pm
-    version: 0.04
+    version: 0.05
   DateTime::Format::Natural::Wrappers:
     file: lib/DateTime/Format/Natural/Wrappers.pm
     version: 0.02

Modified: trunk/libdatetime-format-natural-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/README?rev=64481&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/README (original)
+++ trunk/libdatetime-format-natural-perl/README Tue Nov  2 14:09:03 2010
@@ -83,7 +83,7 @@
 
   parse_datetime_duration
 
-    Returns one or more DateTime object(s) constructed from a human readable
+    Returns one or more DateTime objects constructed from a human readable
     date/time string which may contain timespans/durations. *Same* interface
     and options as `parse_datetime()', but should be explicitly called in
     list context.
@@ -102,9 +102,11 @@
 
   trace
 
-    Returns one or more strings with traces of methods which were called
-    within the Base class and a summary how often certain units have been
-    modified. More than one string is commonly returned for durations.
+    Returns one or more strings with the grammar keyword for the valid
+    expression parsed, traces of methods which were called within the Calc
+    class and a summary how often certain units have been modified. More
+    than one string is commonly returned for durations. Useful as a
+    debugging aid.
 
 GRAMMAR
     The grammar handling has been rewritten to be easily extendable and
@@ -115,8 +117,8 @@
     you're intending to hack a bit on the grammar guts.
 
 EXAMPLES
-    See the classes `DateTime::Format::Natural::Lang::[language_code]' for a
-    overview of currently valid input.
+    See the classes `DateTime::Format::Natural::Lang::[language_code]' for
+    an overview of currently valid input.
 
 BUGS & CAVEATS
     `parse_datetime()'/`parse_datetime_duration()' always return one or more
@@ -163,6 +165,7 @@
      Eric Wilhelm
      Kevin Field
      Wes Morgan
+     Vladimir Marek
 
 SEE ALSO
     DateTime, Date::Calc, http://datetime.perl.org

Modified: trunk/libdatetime-format-natural-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/debian/changelog?rev=64481&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/debian/changelog (original)
+++ trunk/libdatetime-format-natural-perl/debian/changelog Tue Nov  2 14:09:03 2010
@@ -1,3 +1,9 @@
+libdatetime-format-natural-perl (0.91-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Angel Abad <angelabad at gmail.com>  Tue, 02 Nov 2010 15:04:53 +0100
+
 libdatetime-format-natural-perl (0.90-2) UNRELEASED; urgency=low
 
   [ Salvatore Bonaccorso ]

Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm?rev=64481&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm Tue Nov  2 14:09:03 2010
@@ -18,7 +18,7 @@
 use Scalar::Util qw(blessed);
 use Storable qw(dclone);
 
-our $VERSION = '0.90';
+our $VERSION = '0.91';
 
 validation_options(
     on_fail => sub
@@ -123,7 +123,7 @@
 {
     my $self = shift;
 
-    delete @$self{qw(modified postprocess)};
+    delete @$self{qw(keyword modified postprocess)};
 }
 
 sub parse_datetime
@@ -397,6 +397,7 @@
                     $self->$worker(@values, $expression->[4]->[$i++]);
                 }
                 %opts = %{$expression->[6]};
+                $self->{keyword} = $keyword;
                 last PARSE;
             }
         }
@@ -633,7 +634,7 @@
 
 =head2 parse_datetime_duration
 
-Returns one or more L<DateTime> object(s) constructed from a human readable
+Returns one or more L<DateTime> objects constructed from a human readable
 date/time string which may contain timespans/durations. I<Same> interface
 and options as C<parse_datetime()>, but should be explicitly called in
 list context.
@@ -652,9 +653,10 @@
 
 =head2 trace
 
-Returns one or more strings with traces of methods which were called within
-the Base class and a summary how often certain units have been modified.
-More than one string is commonly returned for durations.
+Returns one or more strings with the grammar keyword for the valid
+expression parsed, traces of methods which were called within the Calc
+class and a summary how often certain units have been modified. More than
+one string is commonly returned for durations. Useful as a debugging aid.
 
 =head1 GRAMMAR
 
@@ -666,7 +668,7 @@
 
 =head1 EXAMPLES
 
-See the classes C<DateTime::Format::Natural::Lang::[language_code]> for a
+See the classes C<DateTime::Format::Natural::Lang::[language_code]> for an
 overview of currently valid input.
 
 =head1 BUGS & CAVEATS
@@ -715,6 +717,7 @@
  Eric Wilhelm
  Kevin Field
  Wes Morgan
+ Vladimir Marek
 
 =head1 SEE ALSO
 

Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm?rev=64481&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm Tue Nov  2 14:09:03 2010
@@ -10,7 +10,7 @@
 
 use DateTime::Format::Natural::Helpers qw(%flag);
 
-our $VERSION = '1.38';
+our $VERSION = '1.41';
 
 our (%init,
      %timespan,
@@ -1039,6 +1039,321 @@
          { truncate_to => 'minute' },
        ],
     ],
+    am_pm_variant_weekday => [
+       [ 'REGEXP', 'SCALAR', 'REGEXP', 'REGEXP' ],
+       [
+         { 0 => $RE{time}, 1 => 'am', 2 => qr/^(last)$/i, 3 => $RE{weekday} },
+         [ [ 0 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{time_am} ] },
+           ],
+           [
+             { 2 => [ $flag{last_this_next} ] },
+             { 3 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_count_day_variant_week' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time}, 1 => 'am', 2 => qr/^(this)$/i, 3 => $RE{weekday} },
+         [ [ 0 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{time_am} ] },
+           ],
+           [
+             { 2 => [ $flag{last_this_next} ] },
+             { 3 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_count_day_variant_week' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time}, 1 => 'am', 2 => qr/^(next)$/i, 3 => $RE{weekday} },
+         [ [ 0 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{time_am} ] },
+           ],
+           [
+             { 2 => [ $flag{last_this_next} ] },
+             { 3 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_count_day_variant_week' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time}, 1 => 'pm', 2 => qr/^(last)$/i, 3 => $RE{weekday} },
+         [ [ 0 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{time_pm} ] },
+           ],
+           [
+             { 2 => [ $flag{last_this_next} ] },
+             { 3 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_count_day_variant_week' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time}, 1 => 'pm', 2 => qr/^(this)$/i, 3 => $RE{weekday} },
+         [ [ 0 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{time_pm} ] },
+           ],
+           [
+             { 2 => [ $flag{last_this_next} ] },
+             { 3 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_count_day_variant_week' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time}, 1 => 'pm', 2 => qr/^(next)$/i, 3 => $RE{weekday} },
+         [ [ 0 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{time_pm} ] },
+           ],
+           [
+             { 2 => [ $flag{last_this_next} ] },
+             { 3 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_count_day_variant_week' ],
+         { truncate_to => 'minute' },
+       ],
+    ],
+    variant_weekday_at => [
+       [ 'REGEXP', 'REGEXP', 'REGEXP' ],
+       [
+         { 0 => qr/^(last)$/i, 1 => $RE{weekday}, 2 => $RE{time_am} },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_am} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => qr/^(this)$/i, 1 => $RE{weekday}, 2 => $RE{time_am} },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_am} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => qr/^(next)$/i, 1 => $RE{weekday}, 2 => $RE{time_am} },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_am} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => qr/^(last)$/i, 1 => $RE{weekday}, 2 => $RE{time_pm} },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_pm} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => qr/^(this)$/i, 1 => $RE{weekday}, 2 => $RE{time_pm} },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_pm} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => qr/^(next)$/i, 1 => $RE{weekday}, 2 => $RE{time_pm} },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_pm} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+    ],
+    variant_weekday_am_pm => [
+       [ 'REGEXP', 'REGEXP', 'REGEXP', 'SCALAR' ],
+       [
+         { 0 => qr/^(last)$/i, 1 => $RE{weekday}, 2 => $RE{time}, 3 => 'am' },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_am} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => qr/^(this)$/i, 1 => $RE{weekday}, 2 => $RE{time}, 3 => 'am' },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_am} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => qr/^(next)$/i, 1 => $RE{weekday}, 2 => $RE{time}, 3 => 'am' },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_am} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => qr/^(last)$/i, 1 => $RE{weekday}, 2 => $RE{time}, 3 => 'pm' },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_pm} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => qr/^(this)$/i, 1 => $RE{weekday}, 2 => $RE{time}, 3 => 'pm' },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_pm} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => qr/^(next)$/i, 1 => $RE{weekday}, 2 => $RE{time}, 3 => 'pm' },
+         [ [ 2 ] ],
+         [ $extended_checks{meridiem} ],
+         [
+           [
+             { 0 => [ $flag{last_this_next} ] },
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_pm} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_count_day_variant_week', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+    ],
     month => [
        [ 'REGEXP' ],
        [
@@ -1144,6 +1459,221 @@
          ],
          [ {}, {} ],
          [ '_month_day', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+    ],
+    month_day_am_pm => [
+       [ 'REGEXP', 'REGEXP', 'REGEXP', 'SCALAR' ],
+       [
+         { 0 => $RE{month}, 1 => $RE{monthday}, 2 => $RE{time}, 3 => 'am' },
+         [ [ 1 ], [ 2 ] ],
+         [ $extended_checks{ordinal}, $extended_checks{meridiem} ],
+         [
+           [
+               1,
+             { 0 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_am} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_month_day', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{month}, 1 => $RE{monthday}, 2 => $RE{time}, 3 => 'pm' },
+         [ [ 1 ], [ 2 ] ],
+         [ $extended_checks{ordinal}, $extended_checks{meridiem} ],
+         [
+           [
+               1,
+             { 0 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_pm} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_month_day', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+    ],
+    day_month_at => [
+       [ 'REGEXP', 'REGEXP', 'REGEXP' ],
+       [
+         { 0 => $RE{monthday}, 1 => $RE{month}, 2 => $RE{time} },
+         [ [ 0 ] ],
+         [ $extended_checks{ordinal} ],
+         [
+           [
+               0,
+             { 1 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+           [ 2 ],
+         ],
+         [ {}, {} ],
+         [ '_month_day', '_time' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{monthday}, 1 => $RE{month}, 2 => $RE{time_am} },
+         [ [ 0 ], [ 2 ] ],
+         [ $extended_checks{ordinal}, $extended_checks{meridiem} ],
+         [
+           [
+               0,
+             { 1 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_am} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_month_day', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{monthday}, 1 => $RE{month}, 2 => $RE{time_pm} },
+         [ [ 0 ], [ 2 ] ],
+         [ $extended_checks{ordinal}, $extended_checks{meridiem} ],
+         [
+           [
+               0,
+             { 1 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_pm} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_month_day', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+    ],
+    day_month_am_pm => [
+       [ 'REGEXP', 'REGEXP', 'REGEXP', 'SCALAR' ],
+       [
+         { 0 => $RE{monthday}, 1 => $RE{month}, 2 => $RE{time}, 3 => 'am' },
+         [ [ 0 ], [ 2 ] ],
+         [ $extended_checks{ordinal}, $extended_checks{meridiem} ],
+         [
+           [
+               0,
+             { 1 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_am} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_month_day', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{monthday}, 1 => $RE{month}, 2 => $RE{time}, 3 => 'pm' },
+         [ [ 0 ], [ 2 ] ],
+         [ $extended_checks{ordinal}, $extended_checks{meridiem} ],
+         [
+           [
+               0,
+             { 1 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+           [
+             { 2 => [ $flag{time_pm} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_month_day', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+    ],
+    at_month_day => [
+       [ 'REGEXP', 'REGEXP', 'REGEXP' ],
+       [
+         { 0 => $RE{time}, 1 => $RE{month}, 2 => $RE{monthday} },
+         [ [ 2 ] ],
+         [ $extended_checks{ordinal} ],
+         [
+           [ 0 ],
+           [
+               2,
+             { 1 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_time', '_month_day' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time_am}, 1 => $RE{month}, 2 => $RE{monthday} },
+         [ [ 0 ], [ 2 ] ],
+         [ $extended_checks{meridiem}, $extended_checks{ordinal} ],
+         [
+           [
+             { 0 => [ $flag{time_am} ] },
+           ],
+           [
+               2,
+             { 1 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_month_day' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time_pm}, 1 => $RE{month}, 2 => $RE{monthday} },
+         [ [ 0 ], [ 2 ] ],
+         [ $extended_checks{meridiem}, $extended_checks{ordinal} ],
+         [
+           [
+             { 0 => [ $flag{time_pm} ] },
+           ],
+           [
+               2,
+             { 1 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_month_day' ],
+         { truncate_to => 'minute' },
+       ],
+    ],
+    am_pm_month_day => [
+       [ 'REGEXP', 'SCALAR', 'REGEXP', 'REGEXP' ],
+       [
+         { 0 => $RE{time}, 1 => 'am', 2 => $RE{month}, 3 => $RE{monthday} },
+         [ [ 0 ], [ 3 ] ],
+         [ $extended_checks{meridiem}, $extended_checks{ordinal} ],
+         [
+           [
+             { 0 => [ $flag{time_am} ] },
+           ],
+           [
+               3,
+             { 2 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_month_day' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time}, 1 => 'pm', 2 => $RE{month}, 3 => $RE{monthday} },
+         [ [ 0 ], [ 3 ] ],
+         [ $extended_checks{meridiem}, $extended_checks{ordinal} ],
+         [
+           [
+             { 0 => [ $flag{time_pm} ] },
+           ],
+           [
+               3,
+             { 2 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_month_day' ],
          { truncate_to => 'minute' },
        ],
     ],
@@ -4145,6 +4675,24 @@
  1pm last friday
  1pm this friday
  1pm next friday
+ 5 am last monday
+ 5 am this monday
+ 5 am next monday
+ 5 pm last monday
+ 5 pm this monday
+ 5 pm next monday
+ last wednesday 7am
+ this wednesday 7am
+ next wednesday 7am
+ last wednesday 7pm
+ this wednesday 7pm
+ next wednesday 7pm
+ last tuesday 11 am
+ this tuesday 11 am
+ next tuesday 11 am
+ last tuesday 11 pm
+ this tuesday 11 pm
+ next tuesday 11 pm
  yesterday at 13:00
  today at 13:00
  tomorrow at 13
@@ -4192,10 +4740,22 @@
  march
  january 11
  11 january
+ 18 oct 17:00
+ 18 oct 5am
+ 18 oct 5pm
+ 18 oct 5 am
+ 18 oct 5 pm
  dec 25
  feb 28 3:00
  feb 28 3am
  feb 28 3pm
+ feb 28 3 am
+ feb 28 3 pm
+ 19:00 jul 1
+ 7am jul 1
+ 7pm jul 1
+ 7 am jul 1
+ 7 pm jul 1
  may 27th
  2005
  march 1st 2009

Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Utils.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Utils.pm?rev=64481&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Utils.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Utils.pm Tue Nov  2 14:09:03 2010
@@ -4,7 +4,7 @@
 use warnings;
 use boolean qw(true false);
 
-our $VERSION = '0.04';
+our $VERSION = '0.05';
 
 sub _valid_date
 {
@@ -56,17 +56,18 @@
 {
     my $self = shift;
 
-    my ($trace, $modified) = map $self->{$_}, qw(trace modified);
+    my ($trace, $modified, $keyword) = map $self->{$_}, qw(trace modified keyword);
 
     $trace    ||= [];
     $modified ||= {};
+    $keyword  ||= '';
 
-    return undef unless (@$trace || %$modified);
+    return undef unless (@$trace || %$modified || length $keyword);
 
     my $i;
     my %order = map { $_ => $i++ } @{$self->{data}->__units('ordered')};
 
-    return join "\n", @$trace,
+    return join "\n", grep length, $keyword, @$trace,
       map { my $unit = $_; "$unit: $modified->{$unit}" }
       sort { $order{$a} <=> $order{$b} }
       keys %$modified;

Modified: trunk/libdatetime-format-natural-perl/t/01-parse.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/01-parse.t?rev=64481&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/01-parse.t (original)
+++ trunk/libdatetime-format-natural-perl/t/01-parse.t Tue Nov  2 14:09:03 2010
@@ -227,6 +227,24 @@
     { '1pm last friday'                 => '17.11.2006 13:00:00' },
     { '1pm this friday'                 => '24.11.2006 13:00:00' },
     { '1pm next friday'                 => '01.12.2006 13:00:00' },
+    { '5 am last monday'                => '13.11.2006 05:00:00' },
+    { '5 am this monday'                => '20.11.2006 05:00:00' },
+    { '5 am next monday'                => '27.11.2006 05:00:00' },
+    { '5 pm last monday'                => '13.11.2006 17:00:00' },
+    { '5 pm this monday'                => '20.11.2006 17:00:00' },
+    { '5 pm next monday'                => '27.11.2006 17:00:00' },
+    { 'last wednesday 7am'              => '15.11.2006 07:00:00' },
+    { 'this wednesday 7am'              => '22.11.2006 07:00:00' },
+    { 'next wednesday 7am'              => '29.11.2006 07:00:00' },
+    { 'last wednesday 7pm'              => '15.11.2006 19:00:00' },
+    { 'this wednesday 7pm'              => '22.11.2006 19:00:00' },
+    { 'next wednesday 7pm'              => '29.11.2006 19:00:00' },
+    { 'last tuesday 11 am'              => '14.11.2006 11:00:00' },
+    { 'this tuesday 11 am'              => '21.11.2006 11:00:00' },
+    { 'next tuesday 11 am'              => '28.11.2006 11:00:00' },
+    { 'last tuesday 11 pm'              => '14.11.2006 23:00:00' },
+    { 'this tuesday 11 pm'              => '21.11.2006 23:00:00' },
+    { 'next tuesday 11 pm'              => '28.11.2006 23:00:00' },
     { 'yesterday at 13:00'              => '23.11.2006 13:00:00' },
     { 'today at 13:00'                  => '24.11.2006 13:00:00' },
     { 'tomorrow at 13'                  => '25.11.2006 13:00:00' },
@@ -253,10 +271,22 @@
     { 'march'             => '01.03.2006 00:00:00' },
     { 'january 11'        => '11.01.2006 00:00:00' },
     { '11 january'        => '11.01.2006 00:00:00' },
+    { '18 oct 17:00'      => '18.10.2006 17:00:00' },
+    { '18 oct 5am'        => '18.10.2006 05:00:00' },
+    { '18 oct 5pm'        => '18.10.2006 17:00:00' },
+    { '18 oct 5 am'       => '18.10.2006 05:00:00' },
+    { '18 oct 5 pm'       => '18.10.2006 17:00:00' },
     { 'dec 25'            => '25.12.2006 00:00:00' },
     { 'feb 28 3:00'       => '28.02.2006 03:00:00' },
     { 'feb 28 3am'        => '28.02.2006 03:00:00' },
     { 'feb 28 3pm'        => '28.02.2006 15:00:00' },
+    { 'feb 28 3 am'       => '28.02.2006 03:00:00' },
+    { 'feb 28 3 pm'       => '28.02.2006 15:00:00' },
+    { '19:00 jul 1'       => '01.07.2006 19:00:00' },
+    { '7am jul 1'         => '01.07.2006 07:00:00' },
+    { '7pm jul 1'         => '01.07.2006 19:00:00' },
+    { '7 am jul 1'        => '01.07.2006 07:00:00' },
+    { '7 pm jul 1'        => '01.07.2006 19:00:00' },
     { 'may 27th'          => '27.05.2006 00:00:00' },
   # { '2005'              => '01.01.2005 00:00:00' },
     { 'march 1st 2009'    => '01.03.2009 00:00:00' },
@@ -272,7 +302,7 @@
     { '+2d'               => '26.11.2006 01:13:08' },
 );
 
-_run_tests(255, [ [ \@simple ], [ \@complex ], [ \@specific ] ], \&compare);
+_run_tests(285, [ [ \@simple ], [ \@complex ], [ \@specific ] ], \&compare);
 
 sub compare
 {

Modified: trunk/libdatetime-format-natural-perl/t/10-parse_failure.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/10-parse_failure.t?rev=64481&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/10-parse_failure.t (original)
+++ trunk/libdatetime-format-natural-perl/t/10-parse_failure.t Tue Nov  2 14:09:03 2010
@@ -5,7 +5,7 @@
 use boolean qw(false);
 
 use DateTime::Format::Natural;
-use Test::More tests => 240;
+use Test::More tests => 308;
 
 my %errors = (
     with_suffix      => qr/suffix 's' without plural/,
@@ -143,8 +143,36 @@
     '16pm next friday',
     '16pm this friday',
     '16pm last friday',
+    '13 am last monday',
+    '13 am this monday',
+    '13 am next monday',
+    '13 pm last monday',
+    '13 pm this monday',
+    '13 pm next monday',
+    'last wednesday 14am',
+    'this wednesday 14am',
+    'next wednesday 14am',
+    'last wednesday 14pm',
+    'this wednesday 14pm',
+    'next wednesday 14pm',
+    'last tuesday 15 am',
+    'this tuesday 15 am',
+    'next tuesday 15 am',
+    'last tuesday 15 pm',
+    'this tuesday 15 pm',
+    'next tuesday 15 pm',
+    '18 oct 16am',
+    '18 oct 16pm',
+    '18 oct 16 am',
+    '18 oct 16 pm',
     'may 02 17am',
     'may 02 17pm',
+    'may 02 17 am',
+    'may 02 17 pm',
+    '17am jul 1',
+    '17pm jul 1',
+    '17 am jul 1',
+    '17 pm jul 1',
     '18 am',
     '18 pm',
     '19:00:00 am',
@@ -199,8 +227,36 @@
     '0pm next friday',
     '0pm this friday',
     '0pm last friday',
+    '0 am last monday',
+    '0 am this monday',
+    '0 am next monday',
+    '0 pm last monday',
+    '0 pm this monday',
+    '0 pm next monday',
+    'last wednesday 0am',
+    'this wednesday 0am',
+    'next wednesday 0am',
+    'last wednesday 0pm',
+    'this wednesday 0pm',
+    'next wednesday 0pm',
+    'last tuesday 0 am',
+    'this tuesday 0 am',
+    'next tuesday 0 am',
+    'last tuesday 0 pm',
+    'this tuesday 0 pm',
+    'next tuesday 0 pm',
+    '18 oct 0am',
+    '18 oct 0pm',
+    '18 oct 0 am',
+    '18 oct 0 pm',
     'may 02 0am',
     'may 02 0pm',
+    'may 02 0 am',
+    'may 02 0 pm',
+    '0am jul 1',
+    '0pm jul 1',
+    '0 am jul 1',
+    '0 pm jul 1',
     '0 am',
     '0 pm',
     '00:00:00 am',
@@ -245,9 +301,21 @@
 [
     '4st february',
     'november 3nd',
+    '18nd oct 17:00',
+    '18nd oct 5am',
+    '18nd oct 5pm',
+    '18nd oct 5 am',
+    '18nd oct 5 pm',
     'feb 28rd 3:00',
     'feb 28rd 3am',
     'feb 28rd 3pm',
+    'feb 28rd 3 am',
+    'feb 28rd 3 pm',
+    '19:00 jul 1th',
+    '7am jul 1th',
+    '7pm jul 1th',
+    '7 am jul 1th',
+    '7 pm jul 1th',
     '11st january 2 years ago',
     '11st january next year',
     '11st january this year',

Modified: trunk/libdatetime-format-natural-perl/t/14-trace.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/14-trace.t?rev=64481&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/14-trace.t (original)
+++ trunk/libdatetime-format-natural-perl/t/14-trace.t Tue Nov  2 14:09:03 2010
@@ -15,11 +15,13 @@
     $string = 'now';
     $parser->parse_datetime($string);
     is($stringify->(($parser->trace)[0]), <<'EOT', $string);
+now
 DateTime::Format::Natural::Calc::_no_op
 EOT
     $string = 'yesterday 3 years ago';
     $parser->parse_datetime($string);
     is($stringify->(($parser->trace)[0]), <<'EOT', $string);
+ago_yesterday
 DateTime::Format::Natural::Calc::_unit_variant
 DateTime::Format::Natural::Calc::_ago_variant
 day: 1
@@ -28,8 +30,10 @@
     $string = 'monday to friday';
     $parser->parse_datetime_duration($string);
     is($stringify->($parser->trace), <<'EOT', $string);
+weekday
 DateTime::Format::Natural::Calc::_weekday
 day: 1
+weekday
 DateTime::Format::Natural::Calc::_weekday
 day: 1
 EOT




More information about the Pkg-perl-cvs-commits mailing list