r53213 - in /trunk/libdatetime-format-natural-perl: ./ debian/ lib/DateTime/Format/ lib/DateTime/Format/Natural/ lib/DateTime/Format/Natural/Lang/ t/

angelabad-guest at users.alioth.debian.org angelabad-guest at users.alioth.debian.org
Mon Feb 22 19:52:03 UTC 2010


Author: angelabad-guest
Date: Mon Feb 22 19:51:47 2010
New Revision: 53213

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

Added:
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Aliases.pm
      - copied unchanged from r53207, branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Aliases.pm
    trunk/libdatetime-format-natural-perl/t/09-parse_aliases.t
      - copied unchanged from r53207, branches/upstream/libdatetime-format-natural-perl/current/t/09-parse_aliases.t
    trunk/libdatetime-format-natural-perl/t/10-regression.t
      - copied unchanged from r53207, branches/upstream/libdatetime-format-natural-perl/current/t/10-regression.t
    trunk/libdatetime-format-natural-perl/t/11-state.t
      - copied unchanged from r53207, branches/upstream/libdatetime-format-natural-perl/current/t/11-state.t
    trunk/libdatetime-format-natural-perl/t/12-trace.t
      - copied unchanged from r53207, branches/upstream/libdatetime-format-natural-perl/current/t/12-trace.t
Removed:
    trunk/libdatetime-format-natural-perl/t/09-regression.t
    trunk/libdatetime-format-natural-perl/t/10-state.t
    trunk/libdatetime-format-natural-perl/t/11-trace.t
Modified:
    trunk/libdatetime-format-natural-perl/Changes
    trunk/libdatetime-format-natural-perl/MANIFEST
    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/debian/control
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Compat.pm
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/Base.pm
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Test.pm
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Utils.pm
    trunk/libdatetime-format-natural-perl/t/00-load.t
    trunk/libdatetime-format-natural-perl/t/01-parse.t
    trunk/libdatetime-format-natural-perl/t/02-parse_format.t
    trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t
    trunk/libdatetime-format-natural-perl/t/04-parse_durations.t
    trunk/libdatetime-format-natural-perl/t/05-parse_time_zone.t
    trunk/libdatetime-format-natural-perl/t/06-parse_prefer_future.t
    trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t

Modified: trunk/libdatetime-format-natural-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/Changes?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/Changes (original)
+++ trunk/libdatetime-format-natural-perl/Changes Mon Feb 22 19:51:47 2010
@@ -1,4 +1,37 @@
 Revision history for Perl extension DateTime::Format::Natural.
+
+0.84  2010-02-22  <schubiger at cpan.org>
+
+ - Merged development version to stable.
+
+0.83_04  2010-02-16  <schubiger at cpan.org>
+
+ - Enhance the regular expression matching a non-word alias.
+
+ - Correct the indentation of _Nth_Weekday_of_Month_Year().
+
+0.83_03  2010-02-14  <schubiger at cpan.org>
+
+ - Introduce short name aliases. [rt #53976 - Kevin Field]
+
+ - Support shortened relative dates with a +/- prefix.
+   [rt #53976 - Kevin Field]
+
+ - Add according tests for aliases and prefixed dates.
+
+ - Test for case-insensitive processing of input strings.
+
+ - Test compile-time loading of Aliases.pm.
+
+0.83_02 Wed Jan 27 10:42:41 CET 2010
+
+ - New supported formats: <time> <weekday> and <time> on <weekday>.
+   [rt #53979 - Kevin Field]
+
+0.83_01 Mon Jan 18 10:28:42 CET 2010
+
+ - Pass the time zone object instead of name to the final DateTime
+   constructor. [rt #53268 - Eric Wilhelm]
 
 0.83 Wed Jan 13 15:51:11 CET 2010
 

Modified: trunk/libdatetime-format-natural-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/MANIFEST?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/MANIFEST (original)
+++ trunk/libdatetime-format-natural-perl/MANIFEST Mon Feb 22 19:51:47 2010
@@ -2,6 +2,7 @@
 Changes
 INSTALL
 lib/DateTime/Format/Natural.pm
+lib/DateTime/Format/Natural/Aliases.pm
 lib/DateTime/Format/Natural/Base.pm
 lib/DateTime/Format/Natural/Compat.pm
 lib/DateTime/Format/Natural/Duration.pm
@@ -26,8 +27,9 @@
 t/06-parse_prefer_future.t
 t/07-parse_datetime.t
 t/08-parse_failure.t
-t/09-regression.t
-t/10-state.t
-t/11-trace.t
+t/09-parse_aliases.t
+t/10-regression.t
+t/11-state.t
+t/12-trace.t
 t/pod-coverage.t
 t/pod.t

Modified: trunk/libdatetime-format-natural-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/META.yml?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/META.yml (original)
+++ trunk/libdatetime-format-natural-perl/META.yml Mon Feb 22 19:51:47 2010
@@ -1,6 +1,6 @@
 ---
 name: DateTime-Format-Natural
-version: 0.83
+version: 0.84
 author:
   - 'Steven Schubiger <schubiger at cpan.org>'
 abstract: Create machine readable date/time with natural parsing logic
@@ -29,13 +29,16 @@
 provides:
   DateTime::Format::Natural:
     file: lib/DateTime/Format/Natural.pm
-    version: 0.83
+    version: 0.84
+  DateTime::Format::Natural::Aliases:
+    file: lib/DateTime/Format/Natural/Aliases.pm
+    version: 0.02
   DateTime::Format::Natural::Base:
     file: lib/DateTime/Format/Natural/Base.pm
     version: 1.31
   DateTime::Format::Natural::Compat:
     file: lib/DateTime/Format/Natural/Compat.pm
-    version: 0.06
+    version: 0.07
   DateTime::Format::Natural::Duration:
     file: lib/DateTime/Format/Natural/Duration.pm
     version: 0.04
@@ -47,16 +50,16 @@
     version: 0.05
   DateTime::Format::Natural::Lang::Base:
     file: lib/DateTime/Format/Natural/Lang/Base.pm
-    version: 1.03
+    version: 1.04
   DateTime::Format::Natural::Lang::EN:
     file: lib/DateTime/Format/Natural/Lang/EN.pm
-    version: 1.29
+    version: 1.31
   DateTime::Format::Natural::Test:
     file: lib/DateTime/Format/Natural/Test.pm
-    version: 0.04
+    version: 0.05
   DateTime::Format::Natural::Utils:
     file: lib/DateTime/Format/Natural/Utils.pm
-    version: 0.03
+    version: 0.04
   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=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/README (original)
+++ trunk/libdatetime-format-natural-perl/README Mon Feb 22 19:51:47 2010
@@ -160,6 +160,8 @@
      Christian Brink
      Giovanni Pensa
      Andrew Sterling Hanenkamp
+     Eric Wilhelm
+     Kevin Field
 
 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=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/debian/changelog (original)
+++ trunk/libdatetime-format-natural-perl/debian/changelog Mon Feb 22 19:51:47 2010
@@ -1,3 +1,10 @@
+libdatetime-format-natural-perl (0.84-1) unstable; urgency=low
+
+  * New upstream release
+  * Standards-Version 3.8.4 (no changes)
+
+ -- Angel Abad <angelabad at gmail.com>  Mon, 22 Feb 2010 20:50:55 +0100
+
 libdatetime-format-natural-perl (0.83-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/libdatetime-format-natural-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/debian/control?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/debian/control (original)
+++ trunk/libdatetime-format-natural-perl/debian/control Mon Feb 22 19:51:47 2010
@@ -10,7 +10,7 @@
  gregor herrmann <gregoa at debian.org>, Rene Mayorga <rmayorga at debian.org>,
  Angel Abad <angelabad at gmail.com>, Jonathan Yu <jawnsy at cpan.org>,
  Salvatore Bonaccorso <salvatore.bonaccorso at gmail.com>
-Standards-Version: 3.8.3
+Standards-Version: 3.8.4
 Homepage: http://search.cpan.org/dist/DateTime-Format-Natural/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libdatetime-format-natural-perl/
 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libdatetime-format-natural-perl/

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=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm Mon Feb 22 19:51:47 2010
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 use base qw(
+    DateTime::Format::Natural::Aliases
     DateTime::Format::Natural::Base
     DateTime::Format::Natural::Duration
     DateTime::Format::Natural::Formatted
@@ -12,12 +13,12 @@
 
 use Carp qw(croak);
 use DateTime ();
-use List::MoreUtils qw(all any);
+use List::MoreUtils qw(all any none);
 use Params::Validate ':all';
 use Scalar::Util qw(blessed);
 use Storable qw(dclone);
 
-our $VERSION = '0.83';
+our $VERSION = '0.84';
 
 validation_options(
     on_fail => sub
@@ -136,6 +137,8 @@
     $self->{Input_string} = $self->{Date_string};
 
     my $date_string = $self->{Date_string};
+
+    $self->_rewrite_aliases(\$date_string);
     $date_string =~ tr/,//d;
 
     my ($formatted) = $date_string =~ m!^((?:\d+?[-./])+ (?:\d+?)) \b!x;
@@ -160,6 +163,24 @@
         if ($self->{Prefer_future}) {
             $self->_advance_future(qw(md));
         }
+    }
+    elsif ($date_string =~ /^([+-]) (\d+?) ([a-zA-Z]+)$/x) {
+        my ($prefix, $value, $unit) = ($1, $2, lc $3);
+
+        my %methods = (
+            '+' => '_add',
+            '-' => '_subtract',
+        );
+        my $method = $methods{$prefix};
+
+        if (none { $unit =~ /${_}s?/ } @{$self->{data}->__units('ordered')}) {
+            $self->_set_failure;
+            $self->_set_error("(invalid unit)");
+            return $self->_get_datetime_object;
+        }
+        $self->$method($unit => $value);
+
+        $self->_set_valid_exp;
     }
     else {
         @{$self->{tokens}} = split /\s+/, $date_string;
@@ -482,7 +503,7 @@
     my $self = shift;
 
     my $dt = DateTime->new(
-        time_zone => $self->{datetime}->time_zone->name,
+        time_zone => $self->{datetime}->time_zone,
         year      => $self->{datetime}->year,
         month     => $self->{datetime}->month,
         day       => $self->{datetime}->day_of_month,
@@ -695,6 +716,8 @@
  Christian Brink
  Giovanni Pensa
  Andrew Sterling Hanenkamp
+ Eric Wilhelm
+ Kevin Field
 
 =head1 SEE ALSO
 

Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Compat.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Compat.pm?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Compat.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Compat.pm Mon Feb 22 19:51:47 2010
@@ -8,7 +8,7 @@
 
 our ($VERSION, $Pure);
 
-$VERSION = '0.06';
+$VERSION = '0.07';
 
 BEGIN
 {
@@ -99,22 +99,22 @@
 
 sub _Nth_Weekday_of_Month_Year
 {
-   my $self = shift;
+    my $self = shift;
 
-   if ($Pure) {
-       my ($year, $month, $weekday, $count) = @_;
-       my $dt = $self->{datetime}->clone;
-       $dt->set_year($year);
-       $dt->set_month($month);
-       $dt->set_day(1);
-       $dt->set_day($dt->day + 1)
-         while ($weekday ne $dt->dow);
-       $dt->set_day($dt->day + 7 * ($count - 1));
-       return ($dt->year, $dt->month, $dt->day);
-   }
-   else {
-       return Nth_Weekday_of_Month_Year(@_);
-   }
+    if ($Pure) {
+        my ($year, $month, $weekday, $count) = @_;
+        my $dt = $self->{datetime}->clone;
+        $dt->set_year($year);
+        $dt->set_month($month);
+        $dt->set_day(1);
+        $dt->set_day($dt->day + 1)
+          while ($weekday ne $dt->dow);
+        $dt->set_day($dt->day + 7 * ($count - 1));
+        return ($dt->year, $dt->month, $dt->day);
+    }
+    else {
+        return Nth_Weekday_of_Month_Year(@_);
+    }
 }
 
 sub _check_date

Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/Base.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/Base.pm?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/Base.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/Base.pm Mon Feb 22 19:51:47 2010
@@ -5,7 +5,7 @@
 
 our ($VERSION, $AUTOLOAD);
 
-$VERSION = '1.03';
+$VERSION = '1.04';
 
 sub __new
 {
@@ -23,6 +23,7 @@
     $obj->{conversion}      = \%{"${class}::data_conversion"};
     $obj->{helpers}         = \%{"${class}::data_helpers"};
     $obj->{duration}        = \%{"${class}::data_duration"};
+    $obj->{aliases}         = \%{"${class}::data_aliases"};
 
     return bless $obj, ref($class) || $class;
 }

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=53213&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 Mon Feb 22 19:51:47 2010
@@ -9,10 +9,11 @@
 
 use DateTime::Format::Natural::Helpers qw(%flag);
 
-our $VERSION = '1.29';
+our $VERSION = '1.31';
 
 our (%init,
      %timespan,
+     %units,
      %RE,
      %data_weekdays,
      %data_weekdays_abbrev,
@@ -23,11 +24,13 @@
      %data_conversion,
      %data_helpers,
      %data_duration,
+     %data_aliases,
      %extended_checks,
      %grammar);
 
-%init = (tokens => sub {});
+%init     = (tokens  => sub {});
 %timespan = (literal => 'to');
+%units    = (ordered => [ qw(second minute hour day week month year) ]);
 
 %RE = (number    => qr/^(\d+)$/,
        year      => qr/^(\d{4})$/,
@@ -79,7 +82,7 @@
     );
 
     %data_helpers = (
-        suffix      => qr/s$/,
+        suffix      => qr/s$/i,
         normalize   => sub { ${$_[0]} = ucfirst lc ${$_[0]} },
         abbreviated => sub { length ${$_[0]} == 3 },
     );
@@ -105,6 +108,21 @@
             return (@$date_strings == 2
                 && $date_strings->[0] =~ /^$date \s+ $time$/x
                 && $date_strings->[1] =~ /^$time$/);
+        },
+    );
+
+    %data_aliases = (
+        all => {
+            tues  => 'tue',
+            thurs => 'thu',
+        },
+        tokens => {
+            mins  => 'minutes',
+            '@'   => 'at',
+        },
+        short => {
+            min => 'minute',
+            d   => 'day',
         },
     );
 }
@@ -1507,6 +1525,40 @@
            truncate_to   => 'minute',
          },
        ],
+       [
+         { 0 => $RE{time_am}, 1 => $RE{weekday} },
+         [],
+         [],
+         [
+           [ 0 ],
+           [
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_weekday' ],
+         {
+           prefer_future => true,
+           truncate_to   => 'minute',
+         },
+       ],
+       [
+         { 0 => $RE{time_pm}, 1 => $RE{weekday} },
+         [],
+         [],
+         [
+           [ 0 ],
+           [
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ { hours => 12 }, {} ],
+         [ '_at', '_weekday' ],
+         {
+           prefer_future => true,
+           truncate_to   => 'minute',
+         },
+       ],
     ],
     time => [
        [ 'REGEXP' ],
@@ -1944,7 +1996,7 @@
     weekday_ago_at_time => [
        [ 'REGEXP', 'REGEXP', 'REGEXP', 'SCALAR', 'SCALAR', 'REGEXP' ],
        [
-         { 0 => $RE{weekday}, 1 => $RE{number}, 2 => qr/^(months?)$/, 3 => 'ago', 4 => 'at', 5 => $RE{time_am} },
+         { 0 => $RE{weekday}, 1 => $RE{number}, 2 => qr/^(months?)$/i, 3 => 'ago', 4 => 'at', 5 => $RE{time_am} },
          [ [ 1, 2 ] ],
          [ $extended_checks{suffix} ],
          [
@@ -1959,7 +2011,7 @@
          { truncate_to => 'minute' },
        ],
        [
-         { 0 => $RE{weekday}, 1 => $RE{number}, 2 => qr/^(months?)$/, 3 => 'ago', 4 => 'at', 5 => $RE{time_pm} },
+         { 0 => $RE{weekday}, 1 => $RE{number}, 2 => qr/^(months?)$/i, 3 => 'ago', 4 => 'at', 5 => $RE{time_pm} },
          [ [ 1, 2 ] ],
          [ $extended_checks{suffix} ],
          [
@@ -2983,6 +3035,43 @@
          ],
          [ {}, { hours => 12 } ],
          [ '_weekday', '_at' ],
+         {
+           prefer_future => true,
+           truncate_to   => 'minute',
+         },
+       ],
+    ],
+    time_on_weekday => [
+       [ 'REGEXP', 'SCALAR', 'REGEXP' ],
+       [
+         { 0 => $RE{time_am}, 1 => 'on', 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [ 0 ],
+           [
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_weekday' ],
+         {
+           prefer_future => true,
+           truncate_to   => 'minute',
+         },
+       ],
+       [
+         { 0 => $RE{time_pm}, 1 => 'on', 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [ 0 ],
+           [
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ { hours => 12 }, {} ],
+         [ '_at', '_weekday' ],
          {
            prefer_future => true,
            truncate_to   => 'minute',
@@ -3489,6 +3578,10 @@
  4pm
  4:20pm
  mon 2:35
+ 1am sun
+ 1pm sun
+ 1am on sun
+ 1pm on sun
 
 =head2 Complex
 
@@ -3606,7 +3699,7 @@
  for 4 months
  for 4 years
 
-=head2 Specific Dates
+=head2 Specific
 
  march
  January 11
@@ -3627,6 +3720,17 @@
  4:00
  17:00
  3:20:00
+ -5min
+ +2d
+
+=head2 Aliases
+
+ 5 mins ago
+ yesterday @ noon
+ tues this week
+ final thurs in sep
+ tues
+ thurs
 
 =head1 SEE ALSO
 

Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Test.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Test.pm?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Test.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Test.pm Mon Feb 22 19:51:47 2010
@@ -7,11 +7,11 @@
 
 use Test::More;
 
-our ($VERSION, @EXPORT, %time);
+our ($VERSION, @EXPORT, %time, $case_strings);
 
-$VERSION = '0.04';
+$VERSION = '0.05';
 
- at EXPORT = qw(%time _run_tests _result_string _message);
+ at EXPORT = qw(%time $case_strings _run_tests _result_string _message);
 
 %time = map { split /:/ }
         split /\n/,
@@ -20,9 +20,13 @@
              chomp;
              $_ };
 
+$case_strings = sub { ($_[0], lc $_[0], uc $_[0]) };
+
 sub _run_tests
 {
     my ($tests, $sets, $check) = @_;
+
+    $tests *= 3; # case tests
 
     local $@;
 

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=53213&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 Mon Feb 22 19:51:47 2010
@@ -4,7 +4,7 @@
 use warnings;
 use boolean qw(true false);
 
-our $VERSION = '0.03';
+our $VERSION = '0.04';
 
 sub _valid_date
 {
@@ -64,7 +64,7 @@
     return undef unless (@$trace || %$modified);
 
     my $i;
-    my %order = map { $_ => $i++ } qw(second minute hour day week month year);
+    my %order = map { $_ => $i++ } @{$self->{data}->__units('ordered')};
 
     return join "\n", @$trace,
       map { my $unit = $_; "$unit: $modified->{$unit}" }

Modified: trunk/libdatetime-format-natural-perl/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/00-load.t?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/00-load.t (original)
+++ trunk/libdatetime-format-natural-perl/t/00-load.t Mon Feb 22 19:51:47 2010
@@ -3,12 +3,13 @@
 use strict;
 use warnings;
 
-use Test::More tests => 11;
+use Test::More tests => 12;
 
 BEGIN
 {
     my @modules = qw(
         DateTime::Format::Natural
+        DateTime::Format::Natural::Aliases
         DateTime::Format::Natural::Base
         DateTime::Format::Natural::Compat
         DateTime::Format::Natural::Duration

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=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/01-parse.t (original)
+++ trunk/libdatetime-format-natural-perl/t/01-parse.t Mon Feb 22 19:51:47 2010
@@ -126,6 +126,10 @@
     { '4pm'                   => '24.11.2006 16:00:00' },
     { '4:20pm'                => '24.11.2006 16:20:00' },
     { 'mon 2:35'              => '20.11.2006 02:35:00' },
+    { '1am sun'               => '26.11.2006 01:00:00' },
+    { '1pm sun'               => '26.11.2006 13:00:00' },
+    { '1am on sun'            => '26.11.2006 01:00:00' },
+    { '1pm on sun'            => '26.11.2006 13:00:00' },
 );
 
 my @complex = (
@@ -241,16 +245,21 @@
     { '4:00'              => '24.11.2006 04:00:00' },
     { '17:00'             => '24.11.2006 17:00:00' },
     { '3:20:00'           => '24.11.2006 03:20:00' },
+    { '-5min'             => '24.11.2006 01:08:08' },
+    { '+2d'               => '26.11.2006 01:13:08' },
 );
 
-_run_tests(226, [ [ \@simple ], [ \@complex ], [ \@specific ] ], \&compare);
+_run_tests(232, [ [ \@simple ], [ \@complex ], [ \@specific ] ], \&compare);
 
 sub compare
 {
     my $aref = shift;
+
     foreach my $href (@$aref) {
         my $key = (keys %$href)[0];
-        compare_strings($key, $href->{$key});
+        foreach my $string ($case_strings->($key)) {
+            compare_strings($string, $href->{$key});
+        }
     }
 }
 

Modified: trunk/libdatetime-format-natural-perl/t/02-parse_format.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/02-parse_format.t?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/02-parse_format.t (original)
+++ trunk/libdatetime-format-natural-perl/t/02-parse_format.t Mon Feb 22 19:51:47 2010
@@ -22,9 +22,12 @@
 sub compare
 {
     my $aref = shift;
+
     foreach my $href (@$aref) {
         my $key = (keys %$href)[0];
-        compare_strings($key, $href->{$key}->[0], $href->{$key}->[1]);
+        foreach my $string ($case_strings->($key)) {
+            compare_strings($string, $href->{$key}->[0], $href->{$key}->[1]);
+        }
     }
 }
 

Modified: trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t (original)
+++ trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t Mon Feb 22 19:51:47 2010
@@ -30,9 +30,12 @@
 sub compare
 {
     my ($aref, $opts) = @_;
+
     foreach my $href (@$aref) {
         my $key = (keys %$href)[0];
-        compare_strings($key, $href->{$key}, $opts);
+        foreach my $string ($case_strings->($key)) {
+            compare_strings($string, $href->{$key}, $opts);
+        }
     }
 }
 

Modified: trunk/libdatetime-format-natural-perl/t/04-parse_durations.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/04-parse_durations.t?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/04-parse_durations.t (original)
+++ trunk/libdatetime-format-natural-perl/t/04-parse_durations.t Mon Feb 22 19:51:47 2010
@@ -42,9 +42,12 @@
 sub compare
 {
     my $aref = shift;
+
     foreach my $href (@$aref) {
         my $key = (keys %$href)[0];
-        compare_strings($key, $href->{$key});
+        foreach my $string ($case_strings->($key)) {
+            compare_strings($string, $href->{$key});
+        }
     }
 }
 

Modified: trunk/libdatetime-format-natural-perl/t/05-parse_time_zone.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/05-parse_time_zone.t?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/05-parse_time_zone.t (original)
+++ trunk/libdatetime-format-natural-perl/t/05-parse_time_zone.t Mon Feb 22 19:51:47 2010
@@ -81,9 +81,12 @@
 sub compare
 {
     my $aref = shift;
+
     foreach my $href (@$aref) {
         my $key = (keys %$href)[0];
-        compare_strings($key, $href->{$key});
+        foreach my $string ($case_strings->($key)) {
+            compare_strings($string, $href->{$key});
+        }
     }
 }
 

Modified: trunk/libdatetime-format-natural-perl/t/06-parse_prefer_future.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/06-parse_prefer_future.t?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/06-parse_prefer_future.t (original)
+++ trunk/libdatetime-format-natural-perl/t/06-parse_prefer_future.t Mon Feb 22 19:51:47 2010
@@ -47,6 +47,10 @@
     { 'friday 03:00 pm'    => '24.11.2006 15:00:00' },
     { 'monday at 03:00 am' => '27.11.2006 03:00:00' },
     { 'monday at 03:00 pm' => '27.11.2006 15:00:00' },
+    { '4am thu'            => '30.11.2006 04:00:00' },
+    { '4pm thu'            => '30.11.2006 16:00:00' },
+    { '4am on thu'         => '30.11.2006 04:00:00' },
+    { '4pm on thu'         => '30.11.2006 16:00:00' },
 );
 
 my @formatted = (
@@ -54,14 +58,17 @@
     { '12/24' => '24.12.2006 00:00:00' },
 );
 
-_run_tests(28, [ [ \@simple ], [ \@combined ], [ \@formatted ] ], \&compare);
+_run_tests(32, [ [ \@simple ], [ \@combined ], [ \@formatted ] ], \&compare);
 
 sub compare
 {
     my $aref = shift;
+
     foreach my $href (@$aref) {
         my $key = (keys %$href)[0];
-        compare_strings($key, $href->{$key});
+        foreach my $string ($case_strings->($key)) {
+            compare_strings($string, $href->{$key});
+        }
     }
 }
 

Modified: trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t?rev=53213&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t (original)
+++ trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t Mon Feb 22 19:51:47 2010
@@ -16,9 +16,12 @@
 sub compare
 {
     my $aref = shift;
+
     foreach my $href (@$aref) {
         my $key = (keys %$href)[0];
-        compare_strings($key, $href->{$key});
+        foreach my $string ($case_strings->($key)) {
+            compare_strings($string, $href->{$key});
+        }
     }
 }
 




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