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

carnil-guest at users.alioth.debian.org carnil-guest at users.alioth.debian.org
Fri Aug 7 20:48:48 UTC 2009


Author: carnil-guest
Date: Fri Aug  7 20:48:42 2009
New Revision: 41468

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

Added:
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Test.pm
      - copied unchanged from r41467, branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Test.pm
Modified:
    trunk/libdatetime-format-natural-perl/Build.PL
    trunk/libdatetime-format-natural-perl/Changes
    trunk/libdatetime-format-natural-perl/MANIFEST
    trunk/libdatetime-format-natural-perl/META.yml
    trunk/libdatetime-format-natural-perl/Makefile.PL
    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/Base.pm
    trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.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/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/Build.PL?rev=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/Build.PL (original)
+++ trunk/libdatetime-format-natural-perl/Build.PL Fri Aug  7 20:48:42 2009
@@ -14,6 +14,7 @@
                  'boolean' => 0,
                  'Carp' => 0,
                  'DateTime' => 0,
+                 'Exporter' => 0,
                  'List::MoreUtils' => 0,
                  'Params::Validate' => 0,
                  'Scalar::Util' => 0,

Modified: trunk/libdatetime-format-natural-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/Changes?rev=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/Changes (original)
+++ trunk/libdatetime-format-natural-perl/Changes Fri Aug  7 20:48:42 2009
@@ -1,4 +1,26 @@
 Revision history for Perl extension DateTime::Format::Natural.
+
+0.78 Fri Aug  7 11:32:31 CEST 2009
+
+ - Merged development version to stable.
+
+0.77_01 Thu Jun 25 16:00:27 CEST 2009
+
+ - Add a handful of new formats. [rt #43468 - Clayton L. Scott]
+
+ - Don't eventually try to guess the century.
+
+ - Introduce and use a class for common test routines.
+
+ - Test compile-time loading of Test.pm.
+
+ - Rename the misnamed 'hour' metadata option to 'hours'.
+
+ - _daytime() does not use the 'hours' metadata option when
+   it is set and hence remove such existing entries.
+
+ - For base methods which use the 'hours' metadata option,
+   assume a zero when no value is provided.
 
 0.77 Sun Jun 14 20:46:53 CEST 2009
 

Modified: trunk/libdatetime-format-natural-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/MANIFEST?rev=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/MANIFEST (original)
+++ trunk/libdatetime-format-natural-perl/MANIFEST Fri Aug  7 20:48:42 2009
@@ -7,6 +7,7 @@
 lib/DateTime/Format/Natural/Helpers.pm
 lib/DateTime/Format/Natural/Lang/Base.pm
 lib/DateTime/Format/Natural/Lang/EN.pm
+lib/DateTime/Format/Natural/Test.pm
 Makefile.PL
 MANIFEST			This list of files
 META.yml

Modified: trunk/libdatetime-format-natural-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/META.yml?rev=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/META.yml (original)
+++ trunk/libdatetime-format-natural-perl/META.yml Fri Aug  7 20:48:42 2009
@@ -1,35 +1,38 @@
 ---
 name: DateTime-Format-Natural
-version: 0.77
+version: 0.78
 author:
   - 'Steven Schubiger <schubiger at cpan.org>'
 abstract: Create machine readable date/time with natural parsing logic
 license: perl
 resources:
   license: http://dev.perl.org/licenses/
+build_requires:
+  Test::MockTime: 0
+  Test::More: 0
 requires:
   Carp: 0
   DateTime: 0
+  Exporter: 0
   List::MoreUtils: 0
   Params::Validate: 0
   Scalar::Util: 0
   Storable: 0
   Term::ReadLine: 0
   boolean: 0
-build_requires:
-  Test::MockTime: 0
-  Test::More: 0
 recommends:
   Date::Calc: 0
   Test::Pod: 1.14
   Test::Pod::Coverage: 1.04
+configure_requires:
+  Module::Build: 0.34
 provides:
   DateTime::Format::Natural:
     file: lib/DateTime/Format/Natural.pm
-    version: 0.77
+    version: 0.78
   DateTime::Format::Natural::Base:
     file: lib/DateTime/Format/Natural/Base.pm
-    version: 1.24
+    version: 1.25
   DateTime::Format::Natural::Compat:
     file: lib/DateTime/Format/Natural/Compat.pm
     version: 0.03
@@ -41,8 +44,11 @@
     version: 1.00
   DateTime::Format::Natural::Lang::EN:
     file: lib/DateTime/Format/Natural/Lang/EN.pm
-    version: 1.23
-generated_by: Module::Build version 0.3201
+    version: 1.24
+  DateTime::Format::Natural::Test:
+    file: lib/DateTime/Format/Natural/Test.pm
+    version: 0.01
+generated_by: Module::Build version 0.34
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
   version: 1.4

Modified: trunk/libdatetime-format-natural-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/Makefile.PL?rev=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/Makefile.PL (original)
+++ trunk/libdatetime-format-natural-perl/Makefile.PL Fri Aug  7 20:48:42 2009
@@ -1,4 +1,4 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.32_01
+# Note: this file was auto-generated by Module::Build::Compat version 0.34
 use ExtUtils::MakeMaker;
 WriteMakefile
 (
@@ -14,6 +14,7 @@
                            'DateTime' => 0,
                            'Test::MockTime' => 0,
                            'Storable' => 0,
+                           'Exporter' => 0,
                            'Carp' => 0,
                            'boolean' => 0,
                            'Test::More' => 0,

Modified: trunk/libdatetime-format-natural-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/debian/changelog?rev=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/debian/changelog (original)
+++ trunk/libdatetime-format-natural-perl/debian/changelog Fri Aug  7 20:48:42 2009
@@ -1,4 +1,4 @@
-libdatetime-format-natural-perl (0.77-1) unstable; urgency=low
+libdatetime-format-natural-perl (0.78-1) UNRELEASED; urgency=low
 
   [ Nathan Handler ]
   * debian/watch: Update to ignore development releases.
@@ -13,6 +13,7 @@
   * debian/rules: simplify by using "--with quilt"; adjust build dependencies.
 
   [ Salvatore Bonaccorso ]
+  * New upstream release
   * Bump Standards-Version to 3.8.2 (no changes).
   * Add myself to uploaders 
   * Update debian/copyright to new proposal format, and also add a

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=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm Fri Aug  7 20:48:42 2009
@@ -15,7 +15,7 @@
 use Scalar::Util qw(blessed);
 use Storable qw(dclone);
 
-our $VERSION = '0.77';
+our $VERSION = '0.78';
 
 validation_options(
     on_fail => sub
@@ -190,7 +190,6 @@
             return $self->_get_datetime_object;
         }
 
-        if ($year > $century) { $century-- };
         if (length $year == 2) { $year = "$century$year" };
 
         unless ($self->_check_date($year, $month, $day)) {
@@ -550,16 +549,11 @@
 sub _set_datetime
 {
     my $self = shift;
-    my ($year, $month, $day, $hour, $min, $sec, $tz) = @_;
+    my ($time, $tz) = @_;
 
     $self->{datetime} = DateTime->new(
         time_zone => $tz || 'floating',
-        year      => $year,
-        month     => $month,
-        day       => $day,
-        hour      => $hour,
-        minute    => $min,
-        second    => $sec
+        %$time,
     );
     $self->{running_tests} = true;
 }

Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Base.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Base.pm?rev=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Base.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Base.pm Fri Aug  7 20:48:42 2009
@@ -4,7 +4,7 @@
 use warnings;
 use base qw(DateTime::Format::Natural::Compat);
 
-our $VERSION = '1.24';
+our $VERSION = '1.25';
 
 use constant MORNING   => '08';
 use constant AFTERNOON => '14';
@@ -44,7 +44,7 @@
     $self->_register_trace;
     my $opts = pop;
     my ($hour) = @_;
-    $hour += $opts->{hours};
+    $hour += $opts->{hours} || 0;
     if ($self->_valid_time(hour => $hour)) {
         $self->_set(
             hour   => $hour,
@@ -103,16 +103,17 @@
     my $self = shift;
     $self->_register_trace;
     my $opts = pop;
-    my ($hours, $when) = @_;
-    if ($self->_valid_time(hour => $opts->{hour})) {
-        $self->_set(
-            hour   => $opts->{hour},
+    my ($value, $when) = @_;
+    my $hours = $opts->{hours} || 0;
+    if ($self->_valid_time(hour => $hours)) {
+        $self->_set(
+            hour   => $hours,
             minute => 0,
         );
         $self->_add_or_subtract({
             when  => $when,
             unit  => 'hour',
-            value => $hours,
+            value => $value,
         });
     }
 }

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=41468&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 Fri Aug  7 20:48:42 2009
@@ -9,7 +9,7 @@
 
 use DateTime::Format::Natural::Helpers qw(%flag);
 
-our $VERSION = '1.23';
+our $VERSION = '1.24';
 
 our (%init,
      %timespan,
@@ -263,7 +263,7 @@
              { 2 => [ $flag{noon_midnight} ] },
            ],
          ],
-         [ { unit => 'day' }, { hour => 12 } ],
+         [ { unit => 'day' }, {} ],
          [ '_unit_variant', '_daytime' ],
          {},
        ],
@@ -279,7 +279,7 @@
              { 2 => [ $flag{noon_midnight} ] },
            ],
          ],
-         [ { unit => 'day' }, { hour => 0 } ],
+         [ { unit => 'day' }, {} ],
          [ '_unit_variant', '_daytime' ],
          {},
        ],
@@ -295,7 +295,7 @@
              { 2 => [ $flag{noon_midnight} ] },
            ],
          ],
-         [ { unit => 'day' }, { hour => 12 } ],
+         [ { unit => 'day' }, {} ],
          [ '_unit_variant', '_daytime' ],
          {},
        ],
@@ -311,7 +311,7 @@
              { 2 => [ $flag{noon_midnight} ] },
            ],
          ],
-         [ { unit => 'day' }, { hour => 0 } ],
+         [ { unit => 'day' }, {} ],
          [ '_unit_variant', '_daytime' ],
          {},
        ],
@@ -327,7 +327,7 @@
              { 2 => [ $flag{noon_midnight} ] },
            ]
          ],
-         [ { unit => 'day' }, { hour => 12 } ],
+         [ { unit => 'day' }, {} ],
          [ '_unit_variant', '_daytime' ],
          {},
        ],
@@ -343,8 +343,113 @@
              { 2 => [ $flag{noon_midnight} ] },
            ],
          ],
-         [ { unit => 'day' }, { hour => 0 } ],
+         [ { unit => 'day' }, {} ],
          [ '_unit_variant', '_daytime' ],
+         {},
+       ],
+    ],
+    daytime_variant_weekday => [
+       [ 'REGEXP', 'REGEXP', 'REGEXP' ],
+       [
+         { 0 => qr/^(noon)$/i, 1 => qr/^(next)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [
+             { 0 => [ $flag{noon_midnight} ] },
+           ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_daytime', '_count_day_variant_week' ],
+         {},
+       ],
+       [
+         { 0 => qr/^(midnight)$/i, 1 => qr/^(next)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [
+             { 0 => [ $flag{noon_midnight} ] },
+           ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_daytime', '_count_day_variant_week' ],
+         {},
+       ],
+       [
+         { 0 => qr/^(noon)$/i, 1 => qr/^(this)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [
+             { 0 => [ $flag{noon_midnight} ] },
+           ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_daytime', '_count_day_variant_week' ],
+         {},
+       ],
+       [
+         { 0 => qr/^(midnight)$/i, 1 => qr/^(this)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [
+             { 0 => [ $flag{noon_midnight} ] },
+           ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_daytime', '_count_day_variant_week' ],
+         {},
+       ],
+       [
+         { 0 => qr/^(noon)$/i, 1 => qr/^(last)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [
+             { 0 => [ $flag{noon_midnight} ] },
+           ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_daytime', '_count_day_variant_week' ],
+         {},
+       ],
+       [
+         { 0 => qr/^(midnight)$/i, 1 => qr/^(last)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [
+             { 0 => [ $flag{noon_midnight} ] },
+           ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_daytime', '_count_day_variant_week' ],
          {},
        ],
     ],
@@ -621,6 +726,99 @@
          ],
          [ { hours => 12 }, { unit => 'day' } ],
          [ '_at', '_unit_variant' ],
+         { truncate_to => 'minute' },
+       ],
+    ],
+    at_variant_weekday => [
+       [ 'REGEXP', 'REGEXP', 'REGEXP' ],
+       [
+         { 0 => $RE{time_am}, 1 => qr/^(next)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [ 0 ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_count_day_variant_week' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time_am}, 1 => qr/^(this)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [ 0 ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_count_day_variant_week' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time_am}, 1 => qr/^(last)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [ 0 ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ {}, {} ],
+         [ '_at', '_count_day_variant_week' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time_pm}, 1 => qr/^(next)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [ 0 ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ { hours => 12 }, {} ],
+         [ '_at', '_count_day_variant_week' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time_pm}, 1 => qr/^(this)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [ 0 ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ { hours => 12 }, {} ],
+         [ '_at', '_count_day_variant_week' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{time_pm}, 1 => qr/^(last)$/i, 2 => $RE{weekday} },
+         [],
+         [],
+         [
+           [ 0 ],
+           [
+             { 1 => [ $flag{last_this_next} ] },
+             { 2 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+           ],
+         ],
+         [ { hours => 12 }, {} ],
+         [ '_at', '_count_day_variant_week' ],
          { truncate_to => 'minute' },
        ],
     ],
@@ -679,6 +877,39 @@
            truncate_to   => 'day',
          },
        ]
+    ],
+    month_day_at => [
+       [ 'REGEXP', 'REGEXP', 'REGEXP' ],
+       [
+         { 0 => $RE{month}, 1 => $RE{monthday}, 2 => $RE{time_am} },
+         [],
+         [],
+         [
+           [
+               1,
+             { 0 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+           [ 2 ],
+         ],
+         [ {}, {} ],
+         [ '_month_day', '_at' ],
+         { truncate_to => 'minute' },
+       ],
+       [
+         { 0 => $RE{month}, 1 => $RE{monthday}, 2 => $RE{time_pm} },
+         [],
+         [],
+         [
+           [
+               1,
+             { 0 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+           [ 2 ],
+         ],
+         [ {}, { hours => 12 } ],
+         [ '_month_day', '_at' ],
+         { truncate_to => 'minute' },
+       ],
     ],
     day_month_year_ago => [
       [ 'REGEXP', 'REGEXP', 'REGEXP', 'REGEXP', 'SCALAR' ],
@@ -1168,7 +1399,7 @@
          [],
          [],
          [ [ 0 ] ],
-         [ { hours => 0 } ],
+         [ {} ],
          [ '_at' ],
          {
            prefer_future => true,
@@ -1195,7 +1426,7 @@
          [],
          [],
          [ [ 0 ] ],
-         [ { hours => 0 } ],
+         [ {} ],
          [ '_at' ],
          {
            prefer_future => true,
@@ -1227,7 +1458,7 @@
            ],
            [ 1 ],
          ],
-         [ {}, { hours => 0 } ],
+         [ {}, {} ],
          [ '_weekday', '_time' ],
          {
            prefer_future => true,
@@ -1394,7 +1625,7 @@
          [],
          [],
          [ [ 0 ] ],
-         [ { hours => 0 } ],
+         [ {} ],
          [ '_daytime_in_the_variant' ],
          {},
        ],
@@ -1932,7 +2163,7 @@
            ],
            [ 1 ],
          ],
-         [ {}, { hours => 0 } ],
+         [ {}, {} ],
          [ '_weekday', '_daytime_in_the_variant' ],
          {},
        ],
@@ -2430,7 +2661,7 @@
              { 2 => [ $flag{before_after_from} ] },
            ],
          ],
-         [ { hour => 12 } ],
+         [ { hours => 12 } ],
          [ '_hourtime_variant' ],
          { truncate_to => 'hour' },
        ],
@@ -2444,7 +2675,7 @@
              { 2 => [ $flag{before_after_from} ] },
            ],
          ],
-         [ { hour => 0 } ],
+         [ {} ],
          [ '_hourtime_variant' ],
          { truncate_to => 'hour' },
        ],
@@ -2458,7 +2689,7 @@
              { 2 => [ $flag{before_after_from} ] },
            ],
          ],
-         [ { hour => 12 } ],
+         [ { hours => 12 } ],
          [ '_hourtime_variant' ],
          { truncate_to => 'hour' },
        ],
@@ -2472,7 +2703,7 @@
              { 2 => [ $flag{before_after_from} ] },
            ],
          ],
-         [ { hour => 0 } ],
+         [ {} ],
          [ '_hourtime_variant' ],
          { truncate_to => 'hour' },
        ],
@@ -2680,6 +2911,20 @@
        [ 'SCALAR', 'REGEXP', 'SCALAR', 'REGEXP' ],
        [
          { 0 => 'final', 1 => $RE{weekday}, 2 => 'in', 3 => $RE{month} },
+         [],
+         [],
+         [
+           [
+             { 1 => [ $flag{weekday_name}, $flag{weekday_num} ] },
+             { 3 => [ $flag{month_name}, $flag{month_num} ] },
+           ],
+         ],
+         [ {} ],
+         [ '_final_weekday_in_month' ],
+         { truncate_to => 'day' },
+       ],
+       [
+         { 0 => 'last', 1 => $RE{weekday}, 2 => 'in', 3 => $RE{month} },
          [],
          [],
          [
@@ -2959,9 +3204,21 @@
  10 hours before midnight
  5 hours after noon
  5 hours after midnight
+ noon last friday
+ midnight last friday
+ noon this friday
+ midnight this friday
+ noon next friday
+ midnight next friday
  last friday at 20:00
  this friday at 20:00
  next friday at 20:00
+ 1am last friday
+ 1am this friday
+ 1am next friday
+ 1pm last friday
+ 1pm this friday
+ 1pm next friday
  yesterday at 13:00
  today at 13:00
  tomorrow at 13
@@ -2978,6 +3235,7 @@
  fri 3 months ago at 5am
  wednesday 1 month ago at 8pm
  final thursday in april
+ last thursday in april
 
 =head2 Timespans
 
@@ -2998,6 +3256,8 @@
  January 11
  11 January
  dec 25
+ feb 28 3am
+ feb 28 3pm
  may 27th
  2005
  march 1st 2009

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=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/00-load.t (original)
+++ trunk/libdatetime-format-natural-perl/t/00-load.t Fri Aug  7 20:48:42 2009
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 6;
+use Test::More tests => 7;
 
 BEGIN
 {
@@ -13,4 +13,5 @@
     use_ok('DateTime::Format::Natural::Helpers');
     use_ok('DateTime::Format::Natural::Lang::Base');
     use_ok('DateTime::Format::Natural::Lang::EN');
+    use_ok('DateTime::Format::Natural::Test');
 }

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=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/01-parse.t (original)
+++ trunk/libdatetime-format-natural-perl/t/01-parse.t Fri Aug  7 20:48:42 2009
@@ -2,12 +2,10 @@
 
 use strict;
 use warnings;
-use boolean qw(true);
 
 use DateTime::Format::Natural;
+use DateTime::Format::Natural::Test;
 use Test::More;
-
-my ($sec, $min, $hour, $day, $month, $year) = (8, 13, 1, 24, 11, 2006);
 
 my @simple = (
     { 'now'                   => '24.11.2006 01:13:08' },
@@ -174,9 +172,21 @@
     { '10 hours before midnight'        => '23.11.2006 14:00:00' },
     { '5 hours after noon'              => '24.11.2006 17:00:00' },
     { '5 hours after midnight'          => '24.11.2006 05:00:00' },
+    { 'noon last friday'                => '17.11.2006 12:00:00' },
+    { 'midnight last friday'            => '17.11.2006 00:00:00' },
+    { 'noon this friday'                => '24.11.2006 12:00:00' },
+    { 'midnight this friday'            => '24.11.2006 00:00:00' },
+    { 'noon next friday'                => '01.12.2006 12:00:00' },
+    { 'midnight next friday'            => '01.12.2006 00:00:00' },
     { 'last friday at 20:00'            => '17.11.2006 20:00:00' },
     { 'this friday at 20:00'            => '24.11.2006 20:00:00' },
     { 'next friday at 20:00'            => '01.12.2006 20:00:00' },
+    { '1am last friday'                 => '17.11.2006 01:00:00' },
+    { '1am this friday'                 => '24.11.2006 01:00:00' },
+    { '1am next friday'                 => '01.12.2006 01:00:00' },
+    { '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' },
     { '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' },
@@ -194,6 +204,7 @@
     { 'wednesday 1 month ago at 8pm'    => '25.10.2006 20:00:00' },
     { 'final thursday in april'         => '27.04.2006 00:00:00' },
     { 'final sunday in april'           => '30.04.2006 00:00:00' }, # edge case
+    { 'last thursday in april'          => '27.04.2006 00:00:00' },
 );
 
 my @specific = (
@@ -201,6 +212,8 @@
     { 'january 11'        => '11.01.2006 00:00:00' },
     { '11 january'        => '11.01.2006 00:00:00' },
     { 'dec 25'            => '25.12.2006 00:00:00' },
+    { 'feb 28 3am'        => '28.02.2006 03:00:00' },
+    { 'feb 28 3pm'        => '28.02.2006 15: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' },
@@ -214,27 +227,7 @@
     { '3:20:00'           => '24.11.2006 03:20:00' },
 );
 
-{
-    my $tests = 195;
-
-    local $@;
-
-    if (eval "require Date::Calc") {
-        plan tests => $tests * 2;
-        compare(\@simple);
-        compare(\@complex);
-        compare(\@specific);
-    }
-    else {
-        plan tests => $tests;
-    }
-
-    $DateTime::Format::Natural::Compat::Pure = true;
-
-    compare(\@simple);
-    compare(\@complex);
-    compare(\@specific);
-}
+_run_tests(210, [ [ \@simple ], [ \@complex ], [ \@specific ] ], \&compare);
 
 sub compare
 {
@@ -250,16 +243,16 @@
     my ($string, $result) = @_;
 
     my $parser = DateTime::Format::Natural->new;
-    $parser->_set_datetime($year, $month, $day, $hour, $min, $sec);
+    $parser->_set_datetime(\%time);
 
     my $dt = $parser->parse_datetime($string);
 
     my $res_string = sprintf('%02d.%02d.%4d %02d:%02d:%02d', $dt->day, $dt->month, $dt->year, $dt->hour, $dt->min, $dt->sec);
 
     if ($parser->success) {
-        is($res_string, $result, $string);
+        is($res_string, $result, _message($string));
     }
     else {
-        fail($string);
+        fail(_message($string));
     }
 }

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=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/02-parse_format.t (original)
+++ trunk/libdatetime-format-natural-perl/t/02-parse_format.t Fri Aug  7 20:48:42 2009
@@ -2,38 +2,20 @@
 
 use strict;
 use warnings;
-use boolean qw(true);
 
 use DateTime::Format::Natural;
+use DateTime::Format::Natural::Test;
 use Test::More;
-
-my ($sec, $min, $hour, $day, $month, $year) = (8, 13, 1, 24, 11, 2006);
 
 my @specific = (
     { '27/5/1979'           => [ '27.05.1979 00:00:00', 'dd/m/yyyy'  ] },
     { '5/27/1979'           => [ '27.05.1979 00:00:00', 'mm/d/yyyy'  ] },
-    { '05/27/79'            => [ '27.05.1979 00:00:00', 'mm/dd/yy'   ] },
+    { '05/27/79'            => [ '27.05.2079 00:00:00', 'mm/dd/yy'   ] },
     { '1979-05-27'          => [ '27.05.1979 00:00:00', 'yyyy-mm-dd' ] },
     { '1979-05-27 21:09:14' => [ '27.05.1979 21:09:14', 'yyyy-mm-dd' ] },
 );
 
-{
-    my $tests = 5;
-
-    local $@;
-
-    if (eval "require Date::Calc") {
-        plan tests => $tests * 2;
-        compare(\@specific);
-    }
-    else {
-        plan tests => $tests;
-    }
-
-    $DateTime::Format::Natural::Compat::Pure = true;
-
-    compare(\@specific);
-}
+_run_tests(5, [ [ \@specific ] ], \&compare);
 
 sub compare
 {
@@ -49,16 +31,16 @@
     my ($string, $result, $format) = @_;
 
     my $parser = DateTime::Format::Natural->new(format => $format);
-    $parser->_set_datetime($year, $month, $day, $hour, $min, $sec);
+    $parser->_set_datetime(\%time);
 
     my $dt = $parser->parse_datetime($string);
 
     my $res_string = sprintf('%02d.%02d.%4d %02d:%02d:%02d', $dt->day, $dt->month, $dt->year, $dt->hour, $dt->min, $dt->sec);
 
     if ($parser->success) {
-        is($res_string, $result, $string);
+        is($res_string, $result, _message($string));
     }
     else {
-        fail($string);
+        fail(_message($string));
     }
 }

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=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t (original)
+++ trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t Fri Aug  7 20:48:42 2009
@@ -2,12 +2,10 @@
 
 use strict;
 use warnings;
-use boolean qw(true);
 
 use DateTime::Format::Natural;
+use DateTime::Format::Natural::Test;
 use Test::More;
-
-my ($sec, $min, $hour, $day, $month, $year) = (8, 13, 1, 24, 11, 2006);
 
 my @daytime_regular = (
     { 'morning'   => '24.11.2006 08:00:00' },
@@ -21,31 +19,13 @@
     { 'evening'   => '24.11.2006 19:00:00' },
 );
 
-{
-    my $tests = 6;
+my %opts = (
+    morning   =>  6,
+    afternoon => 13,
+    evening   => 19,
+);
 
-    local $@;
-
-    my %opts = (
-        morning   => 06,
-        afternoon => 13,
-        evening   => 19,
-    );
-
-    if (eval "require Date::Calc") {
-        plan tests => $tests * 2;
-        compare(\@daytime_regular);
-        compare(\@daytime_user, \%opts);
-    }
-    else {
-        plan tests => $tests;
-    }
-
-    $DateTime::Format::Natural::Compat::Pure = true;
-
-    compare(\@daytime_regular);
-    compare(\@daytime_user, \%opts);
-}
+_run_tests(6, [ [ \@daytime_regular ], [ \@daytime_user, \%opts ] ], \&compare);
 
 sub compare
 {
@@ -61,16 +41,16 @@
     my ($string, $result, $opts) = @_;
 
     my $parser = DateTime::Format::Natural->new(daytime => $opts || {});
-    $parser->_set_datetime($year, $month, $day, $hour, $min, $sec);
+    $parser->_set_datetime(\%time);
 
     my $dt = $parser->parse_datetime($string);
 
     my $res_string = sprintf('%02d.%02d.%4d %02d:%02d:%02d', $dt->day, $dt->month, $dt->year, $dt->hour, $dt->min, $dt->sec);
 
     if ($parser->success) {
-        is($res_string, $result, $string);
+        is($res_string, $result, _message($string));
     }
     else {
-        fail($string);
+        fail(_message($string));
     }
 }

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=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/04-parse_durations.t (original)
+++ trunk/libdatetime-format-natural-perl/t/04-parse_durations.t Fri Aug  7 20:48:42 2009
@@ -5,9 +5,8 @@
 use boolean qw(true);
 
 use DateTime::Format::Natural;
+use DateTime::Format::Natural::Test;
 use Test::More;
-
-my ($sec, $min, $hour, $day, $month, $year) = (8, 13, 1, 24, 11, 2006);
 
 my @absolute = (
     { 'monday to friday' => [ '20.11.2006 00:00:00', '24.11.2006 00:00:00' ] },
@@ -26,25 +25,7 @@
     { 'for 4 years'              => [ '24.11.2006 01:13:08', '24.11.2010 01:13:08' ] },
 );
 
-{
-    my $tests = 11;
-
-    local $@;
-
-    if (eval "require Date::Calc") {
-        plan tests => $tests * 2;
-        compare(\@absolute);
-        compare(\@relative);
-    }
-    else {
-        plan tests => $tests;
-    }
-
-    $DateTime::Format::Natural::Compat::Pure = true;
-
-    compare(\@absolute);
-    compare(\@relative);
-}
+_run_tests(11, [ [ \@absolute ], [ \@relative ] ], \&compare);
 
 sub compare
 {
@@ -60,7 +41,7 @@
     my ($string, $result) = @_;
 
     my $parser = DateTime::Format::Natural->new;
-    $parser->_set_datetime($year, $month, $day, $hour, $min, $sec);
+    $parser->_set_datetime(\%time);
 
     my @dt = $parser->parse_datetime_duration($string);
 
@@ -71,9 +52,9 @@
     }
 
     if ($parser->success && $pass && scalar @dt == 2) {
-        ok($pass, $string);
+        ok($pass, _message($string));
     }
     else {
-        fail($string);
+        fail(_message($string));
     }
 }

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=41468&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 Fri Aug  7 20:48:42 2009
@@ -2,12 +2,10 @@
 
 use strict;
 use warnings;
-use boolean qw(true);
 
 use DateTime::Format::Natural;
+use DateTime::Format::Natural::Test;
 use Test::More;
-
-my ($sec, $min, $hour, $day, $month, $year) = (8, 13, 1, 24, 11, 2006);
 
 my @simple = (
     { 'now'                   => '24.11.2006 01:13:08' },
@@ -78,23 +76,7 @@
     { 'thursday last week'    => '16.11.2006 00:00:00' },
 );
 
-{
-    my $tests = 66;
-
-    local $@;
-
-    if (eval "require Date::Calc") {
-        plan tests => $tests * 2;
-        compare(\@simple);
-    }
-    else {
-        plan tests => $tests;
-    }
-
-    $DateTime::Format::Natural::Compat::Pure = true;
-
-    compare(\@simple);
-}
+_run_tests(66, [ [ \@simple ] ], \&compare);
 
 sub compare
 {
@@ -110,17 +92,16 @@
     my ($string, $result) = @_;
 
     my $parser = DateTime::Format::Natural->new(time_zone => 'UTC');
-    $parser->_set_datetime($year, $month, $day, $hour, $min, $sec, 'Asia/Tokyo');
+    $parser->_set_datetime(\%time, 'Asia/Tokyo');
 
     my $dt = $parser->parse_datetime($string);
 
     my $res_string = sprintf('%02d.%02d.%4d %02d:%02d:%02d', $dt->day, $dt->month, $dt->year, $dt->hour, $dt->min, $dt->sec);
 
     if ($parser->success) {
-        is($res_string, $result, $string);
+        is($res_string, $result, _message($string));
     }
     else {
-        fail($string);
+        fail(_message($string));
     }
 }
-

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=41468&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 Fri Aug  7 20:48:42 2009
@@ -6,10 +6,16 @@
 
 use Test::MockTime qw(set_fixed_time);
 use DateTime::Format::Natural;
+use DateTime::Format::Natural::Test;
 use Test::More;
 
-my ($sec, $min, $hour, $day, $month, $year) = (8, 13, 1, 24, 11, 2006);
-set_fixed_time("$day.$month.$year $hour:$min:$sec", '%d.%m.%Y %H:%M:%S');
+my $date = join '.', map $time{$_}, qw(day month year);
+my $time = join ':', map $time{$_}, qw(hour minute second);
+
+set_fixed_time(
+    "$date $time",
+    '%d.%m.%Y %H:%M:%S',
+);
 
 my @simple = (
     { 'friday'       => '24.11.2006 00:00:00' },
@@ -39,25 +45,7 @@
     { 'wednesday at 4pm' => '29.11.2006 16:00:00' },
 );
 
-{
-    my $tests = 22;
-
-    local $@;
-
-    if (eval "require Date::Calc") {
-        plan tests => $tests * 2;
-        compare(\@simple);
-        compare(\@combined);
-    }
-    else {
-        plan tests => $tests;
-    }
-
-    $DateTime::Format::Natural::Compat::Pure = true;
-
-    compare(\@simple);
-    compare(\@combined);
-}
+_run_tests(22, [ [ \@simple ], [ \@combined ] ], \&compare);
 
 sub compare
 {
@@ -78,9 +66,9 @@
     my $res_string = sprintf('%02d.%02d.%4d %02d:%02d:%02d', $dt->day, $dt->month, $dt->year, $dt->hour, $dt->min, $dt->sec);
 
     if ($parser->success) {
-        is($res_string, $result, $string);
+        is($res_string, $result, _message($string));
     }
     else {
-        fail($string);
+        fail(_message($string));
     }
 }

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=41468&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t (original)
+++ trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t Fri Aug  7 20:48:42 2009
@@ -2,34 +2,16 @@
 
 use strict;
 use warnings;
-use boolean qw(true);
 
 use DateTime::Format::Natural;
+use DateTime::Format::Natural::Test;
 use Test::More;
-
-my ($sec, $min, $hour, $day, $month, $year) = (8, 13, 1, 24, 11, 2006);
 
 my @simple = (
     { 'now' => '24.11.2006 01:13:08' },
 );
 
-{
-    my $tests = 1;
-
-    local $@;
-
-    if (eval "require Date::Calc") {
-        plan tests => $tests * 2;
-        compare(\@simple);
-    }
-    else {
-        plan tests => $tests;
-    }
-
-    $DateTime::Format::Natural::Compat::Pure = true;
-
-    compare(\@simple);
-}
+_run_tests(1, [ [ \@simple ] ], \&compare);
 
 sub compare
 {
@@ -44,24 +26,15 @@
 {
     my ($string, $result) = @_;
 
-    my $parser = DateTime::Format::Natural->new(
-        datetime => DateTime->new(
-            year   => $year,
-            month  => $month,
-            day    => $day,
-            hour   => $hour,
-            minute => $min,
-            second => $sec,
-        ),
-    );
+    my $parser = DateTime::Format::Natural->new(datetime => DateTime->new(%time));
     my $dt = $parser->parse_datetime($string);
 
     my $res_string = sprintf('%02d.%02d.%4d %02d:%02d:%02d', $dt->day, $dt->month, $dt->year, $dt->hour, $dt->min, $dt->sec);
 
     if ($parser->success) {
-        is($res_string, $result, $string);
+        is($res_string, $result, _message($string));
     }
     else {
-        fail($string);
+        fail(_message($string));
     }
 }




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