r44363 - in /branches/upstream/libdatetime-format-natural-perl/current: ./ lib/DateTime/Format/ lib/DateTime/Format/Natural/ lib/DateTime/Format/Natural/Lang/ scripts/ t/

carnil-guest at users.alioth.debian.org carnil-guest at users.alioth.debian.org
Sat Sep 19 23:06:15 UTC 2009


Author: carnil-guest
Date: Sat Sep 19 23:06:09 2009
New Revision: 44363

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=44363
Log:
[svn-upgrade] Integrating new upstream version, libdatetime-format-natural-perl (0.79)

Added:
    branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Duration.pm
    branches/upstream/libdatetime-format-natural-perl/current/t/10-state.t   (with props)
Modified:
    branches/upstream/libdatetime-format-natural-perl/current/Changes
    branches/upstream/libdatetime-format-natural-perl/current/MANIFEST
    branches/upstream/libdatetime-format-natural-perl/current/META.yml
    branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural.pm
    branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Base.pm
    branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Compat.pm
    branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Lang/Base.pm
    branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Lang/EN.pm
    branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Test.pm
    branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse
    branches/upstream/libdatetime-format-natural-perl/current/t/00-load.t
    branches/upstream/libdatetime-format-natural-perl/current/t/01-parse.t
    branches/upstream/libdatetime-format-natural-perl/current/t/02-parse_format.t
    branches/upstream/libdatetime-format-natural-perl/current/t/03-parse_daytime.t
    branches/upstream/libdatetime-format-natural-perl/current/t/04-parse_durations.t
    branches/upstream/libdatetime-format-natural-perl/current/t/05-parse_time_zone.t
    branches/upstream/libdatetime-format-natural-perl/current/t/06-parse_prefer_future.t
    branches/upstream/libdatetime-format-natural-perl/current/t/07-parse_datetime.t
    branches/upstream/libdatetime-format-natural-perl/current/t/09-regression.t

Modified: branches/upstream/libdatetime-format-natural-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/Changes?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/Changes (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/Changes Sat Sep 19 23:06:09 2009
@@ -1,4 +1,33 @@
 Revision history for Perl extension DateTime::Format::Natural.
+
+0.79 Sat Sep 19 12:23:20 CEST 2009
+
+ - Merged development version to stable.
+
+0.78_03 Thu Sep 17 12:13:08 CEST 2009
+
+ - Relocate the formatted string printing of result strings
+   used within the tests to the Test class.
+
+0.78_02 Mon Sep 14 17:18:40 CEST 2009
+
+ - Add support for ranges representing the first and last day
+   of a month or year. [rt #44067 - Michael Reddick]
+
+ - Move the insertion code in parse_datetime_duration() to the
+   Duration class and the checks to the english metadata class.
+
+ - Quote for parsing failures with duration strings the entire
+   input string instead of a partial date string.
+
+ - Save and restore state for parse_datetime_duration().
+
+ - Test compile-time loading of Duration.pm.
+
+0.78_01 Tue Sep  1 15:51:59 CEST 2009
+
+ - Set units at once within _check_date() when Date::Calc is
+   not available and add a test. [rt #49326 - Clayton L. Scott]
 
 0.78 Fri Aug  7 11:32:31 CEST 2009
 

Modified: branches/upstream/libdatetime-format-natural-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/MANIFEST?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/MANIFEST (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/MANIFEST Sat Sep 19 23:06:09 2009
@@ -4,6 +4,7 @@
 lib/DateTime/Format/Natural.pm
 lib/DateTime/Format/Natural/Base.pm
 lib/DateTime/Format/Natural/Compat.pm
+lib/DateTime/Format/Natural/Duration.pm
 lib/DateTime/Format/Natural/Helpers.pm
 lib/DateTime/Format/Natural/Lang/Base.pm
 lib/DateTime/Format/Natural/Lang/EN.pm
@@ -23,5 +24,6 @@
 t/07-parse_datetime.t
 t/08-parse_failure.t
 t/09-regression.t
+t/10-state.t
 t/pod-coverage.t
 t/pod.t

Modified: branches/upstream/libdatetime-format-natural-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/META.yml?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/META.yml (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/META.yml Sat Sep 19 23:06:09 2009
@@ -1,6 +1,6 @@
 ---
 name: DateTime-Format-Natural
-version: 0.78
+version: 0.79
 author:
   - 'Steven Schubiger <schubiger at cpan.org>'
 abstract: Create machine readable date/time with natural parsing logic
@@ -29,25 +29,28 @@
 provides:
   DateTime::Format::Natural:
     file: lib/DateTime/Format/Natural.pm
-    version: 0.78
+    version: 0.79
   DateTime::Format::Natural::Base:
     file: lib/DateTime/Format/Natural/Base.pm
-    version: 1.25
+    version: 1.26
   DateTime::Format::Natural::Compat:
     file: lib/DateTime/Format/Natural/Compat.pm
-    version: 0.03
+    version: 0.04
+  DateTime::Format::Natural::Duration:
+    file: lib/DateTime/Format/Natural/Duration.pm
+    version: 0.01
   DateTime::Format::Natural::Helpers:
     file: lib/DateTime/Format/Natural/Helpers.pm
     version: 0.02
   DateTime::Format::Natural::Lang::Base:
     file: lib/DateTime/Format/Natural/Lang/Base.pm
-    version: 1.00
+    version: 1.01
   DateTime::Format::Natural::Lang::EN:
     file: lib/DateTime/Format/Natural/Lang/EN.pm
-    version: 1.24
+    version: 1.25
   DateTime::Format::Natural::Test:
     file: lib/DateTime/Format/Natural/Test.pm
-    version: 0.01
+    version: 0.02
 generated_by: Module::Build version 0.34
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html

Modified: branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural.pm?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural.pm (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural.pm Sat Sep 19 23:06:09 2009
@@ -4,6 +4,7 @@
 use warnings;
 use base qw(
     DateTime::Format::Natural::Base
+    DateTime::Format::Natural::Duration
     DateTime::Format::Natural::Helpers
 );
 use boolean qw(true false);
@@ -15,7 +16,7 @@
 use Scalar::Util qw(blessed);
 use Storable qw(dclone);
 
-our $VERSION = '0.78';
+our $VERSION = '0.79';
 
 validation_options(
     on_fail => sub
@@ -131,6 +132,8 @@
 
     $self->_parse_init(@_);
 
+    $self->{Input_string} = $self->{Date_string};
+
     my $date_string = $self->{Date_string};
     $date_string =~ tr/,//d;
 
@@ -304,26 +307,27 @@
       : do { $self->{duration} = false;
              ($duration_string) };
 
-    my $dt_now;
-    if (scalar @date_strings == 1
-         && $date_strings[0] =~ /^for\s+/i
-    ) {
-        $dt_now = $self->parse_datetime('now');
-    }
+    $self->_pre_duration(\@date_strings);
 
     my @queue;
     foreach my $date_string (@date_strings) {
         push @queue, $self->parse_datetime($date_string);
-    }
-
-    if ($self->success && defined $dt_now) {
-        unshift @queue, $dt_now;
-    }
-
-    foreach my $member (qw(duration formatted)) {
+        $self->_save_state(
+            valid_expression => $self->_get_valid_exp,
+            failure          => $self->_get_failure,
+            error            => $self->_get_error,
+        );
+    }
+
+    $self->_post_duration(\@queue);
+    $self->_restore_state;
+
+    foreach my $member (qw(duration formatted insert state)) {
         delete $self->{$member};
     }
 
+    $self->{Input_string} = $duration_string;
+
     return @queue;
 }
 
@@ -340,7 +344,7 @@
 
     return '' if $self->success;
 
-    my $error  = "'$self->{Date_string}' does not parse ";
+    my $error  = "'$self->{Input_string}' does not parse ";
        $error .= $self->_get_error || '(perhaps you have some garbage?)';
 
     return $error;

Modified: branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Base.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Base.pm?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Base.pm (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Base.pm Sat Sep 19 23:06:09 2009
@@ -4,7 +4,7 @@
 use warnings;
 use base qw(DateTime::Format::Natural::Compat);
 
-our $VERSION = '1.25';
+our $VERSION = '1.26';
 
 use constant MORNING   => '08';
 use constant AFTERNOON => '14';
@@ -402,6 +402,25 @@
     );
 }
 
+sub _first_last_day_unit
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($year, $month, $day) = do {
+        @_ >= 3 ? @_ : (undef, @_);
+    };
+    $year ||= $self->{datetime}->year;
+    unless (defined $day) {
+        $day = $self->_Days_in_Month($year, $month);
+    }
+    $self->_set(
+        year  => $year,
+        month => $month,
+        day   => $day,
+    );
+}
+
 1;
 __END__
 

Modified: branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Compat.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Compat.pm?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Compat.pm (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Compat.pm Sat Sep 19 23:06:09 2009
@@ -8,7 +8,7 @@
 
 our ($VERSION, $Pure);
 
-$VERSION = '0.03';
+$VERSION = '0.04';
 
 BEGIN
 {
@@ -126,9 +126,7 @@
         local $@;
         eval {
             my $dt = $self->{datetime}->clone;
-            $dt->set_year($year);
-            $dt->set_month($month);
-            $dt->set_day($day);
+            $dt->set(year => $year, month => $month, day => $day);
         };
         return !$@;
     }

Added: branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Duration.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Duration.pm?rev=44363&op=file
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Duration.pm (added)
+++ branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Duration.pm Sat Sep 19 23:06:09 2009
@@ -1,0 +1,101 @@
+package DateTime::Format::Natural::Duration;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.01';
+
+sub _pre_duration
+{
+    my $self = shift;
+    my ($date_strings) = @_;
+
+    my $duration = $self->{data}->{duration};
+
+    if ($duration->{for}->($date_strings)) {
+        $self->{insert} = $self->parse_datetime('now');
+    }
+    elsif ($duration->{first_last}->($date_strings)) {
+        if (my ($complete) = $date_strings->[1] =~ /^\S+? \s+ (.*)/x) {
+            $date_strings->[0] .= " $complete";
+        }
+    }
+}
+
+sub _post_duration
+{
+    my $self = shift;
+    my ($queue) = @_;
+
+    if (exists $self->{insert}) {
+        unshift @$queue, $self->{insert};
+    }
+}
+
+sub _save_state
+{
+    my $self = shift;
+    my %args = @_;
+
+    return if scalar keys %{$self->{state}};
+
+    unless ($args{valid_expression}) {
+        %{$self->{state}} = %args;
+    }
+}
+
+sub _restore_state
+{
+    my $self = shift;
+
+    my %state = %{$self->{state}};
+
+    if (scalar keys %state) {
+        $state{valid_expression}
+          ? $self->_set_valid_exp
+          : $self->_unset_valid_exp;
+
+        $state{failure}
+          ? $self->_set_failure
+          : $self->_unset_failure;
+
+        defined $state{error}
+          ? $self->_set_error($state{error})
+          : $self->_unset_error;
+    }
+}
+
+1;
+__END__
+
+=head1 NAME
+
+DateTime::Format::Natural::Duration - Duration hooks and state handling
+
+=head1 SYNOPSIS
+
+ Please see the DateTime::Format::Natural documentation.
+
+=head1 DESCRIPTION
+
+The C<DateTime::Format::Natural::Duration> class contains code to alter
+tokens before parsing and to insert DateTime objects in the resulting
+queue. Furthermore, there's code to save the state of the first failing
+parse and restore it after the duration has been processed.
+
+=head1 SEE ALSO
+
+L<DateTime::Format::Natural>
+
+=head1 AUTHOR
+
+Steven Schubiger <schubiger at cpan.org>
+
+=head1 LICENSE
+
+This program is free software; you may redistribute it and/or
+modify it under the same terms as Perl itself.
+
+See L<http://www.perl.com/perl/misc/Artistic.html>
+
+=cut

Modified: branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Lang/Base.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Lang/Base.pm?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Lang/Base.pm (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Lang/Base.pm Sat Sep 19 23:06:09 2009
@@ -5,7 +5,7 @@
 
 our ($VERSION, $AUTOLOAD);
 
-$VERSION = '1.00';
+$VERSION = '1.01';
 
 sub __new
 {
@@ -22,6 +22,7 @@
     $obj->{months_all}      = \@{$class.'::'.'data_months_all'};
     $obj->{conversion}      = \%{$class.'::'.'data_conversion'};
     $obj->{helpers}         = \%{$class.'::'.'data_helpers'};
+    $obj->{duration}        = \%{$class.'::'.'data_duration'};
 
     return bless $obj, ref($class) || $class;
 }

Modified: branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Lang/EN.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Lang/EN.pm?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Lang/EN.pm (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Lang/EN.pm Sat Sep 19 23:06:09 2009
@@ -9,7 +9,7 @@
 
 use DateTime::Format::Natural::Helpers qw(%flag);
 
-our $VERSION = '1.24';
+our $VERSION = '1.25';
 
 our (%init,
      %timespan,
@@ -22,6 +22,7 @@
      @data_months_all,
      %data_conversion,
      %data_helpers,
+     %data_duration,
      %extended_checks,
      %grammar);
 
@@ -81,6 +82,20 @@
         suffix      => qr/s$/,
         normalize   => sub { ${$_[0]} = ucfirst lc ${$_[0]} },
         abbreviated => sub { length ${$_[0]} == 3 },
+    );
+
+    %data_duration = (
+        for => sub {
+            my ($date_strings) = @_;
+            return (scalar @$date_strings == 1
+                && $date_strings->[0] =~ /^for\s+/i);
+        },
+        first_last => sub {
+            my ($date_strings) = @_;
+            return (scalar @$date_strings == 2
+                && $date_strings->[0] =~ /^first$/i
+                && $date_strings->[1] =~ /^last\s+/i);
+        },
     );
 }
 
@@ -3016,6 +3031,67 @@
          [ { unit => 'year' } ],
          [ '_in_count_variant' ],
          {},
+       ],
+    ],
+    first_last_day_unit => [
+       [ 'SCALAR', 'SCALAR', 'SCALAR', 'REGEXP' ],
+       [
+         { 0 => 'first', 1 => 'day', 2 => 'of', 3 => $RE{month} },
+         [],
+         [],
+         [
+           [
+             { 3 => [ $flag{month_name}, $flag{month_num} ] },
+             { VALUE => 1 },
+           ],
+         ],
+         [ {} ],
+         [ '_first_last_day_unit' ],
+         { truncate_to => 'day' },
+       ],
+       [
+         { 0 => 'first', 1 => 'day', 2 => 'of', 3 => $RE{year} },
+         [],
+         [],
+         [
+           [
+               3,
+             { VALUE => 1 },
+             { VALUE => 1 },
+           ],
+         ],
+         [ {} ],
+         [ '_first_last_day_unit' ],
+         { truncate_to => 'day' },
+       ],
+       [
+         { 0 => 'last', 1 => 'day', 2 => 'of', 3 => $RE{month} },
+         [],
+         [],
+         [
+           [
+             { 3 => [ $flag{month_name}, $flag{month_num} ] },
+             { VALUE => undef },
+           ],
+         ],
+         [ {} ],
+         [ '_first_last_day_unit' ],
+         { truncate_to => 'day' },
+       ],
+       [
+         { 0 => 'last', 1 => 'day', 2 => 'of', 3 => $RE{year} },
+         [],
+         [],
+         [
+           [
+                3,
+              { VALUE => 12 },
+              { VALUE => undef },
+            ],
+         ],
+         [ {} ],
+         [ '_first_last_day_unit' ],
+         { truncate_to => 'day' },
        ],
     ],
 );
@@ -3242,6 +3318,10 @@
  Monday to Friday
  1 April to 31 August
  2009-03-10 9:00 to 11:00
+ first day of 2009 to last day of 2009
+ first day of may to last day of may
+ first to last day of 2008
+ first to last day of september
  for 4 seconds
  for 4 minutes
  for 4 hours

Modified: branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Test.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Test.pm?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Test.pm (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Test.pm Sat Sep 19 23:06:09 2009
@@ -9,7 +9,7 @@
 
 our ($VERSION, @EXPORT, %time);
 
-$VERSION = '0.01';
+$VERSION = '0.02';
 
 %time = (
     year   => 2006,
@@ -19,7 +19,7 @@
     minute => 13,
     second => 8,
 );
- at EXPORT = qw(%time _run_tests _message);
+ at EXPORT = qw(%time _run_tests _result_string _message);
 
 sub _run_tests
 {
@@ -42,6 +42,18 @@
     foreach my $set (@$sets) {
         $check->(@$set);
     }
+}
+
+sub _result_string
+{
+    my ($dt) = @_;
+
+    my $string = sprintf(
+        '%02d.%02d.%4d %02d:%02d:%02d',
+        map $dt->$_, qw(day month year hour min sec)
+    );
+
+    return $string;
 }
 
 sub _message

Modified: branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse Sat Sep 19 23:06:09 2009
@@ -122,7 +122,7 @@
 
         if ($parser->success) {
             foreach my $dt (@dt) {
-                printf("%02d.%02d.%4d %02d:%02d:%02d\n", $dt->day, $dt->month, $dt->year, $dt->hour, $dt->min, $dt->sec);
+                printf("%02d.%02d.%4d %02d:%02d:%02d\n", map $dt->$_, qw(day month year hour min sec));
             }
         }
         else {

Modified: branches/upstream/libdatetime-format-natural-perl/current/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/00-load.t?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/00-load.t (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/00-load.t Sat Sep 19 23:06:09 2009
@@ -3,15 +3,19 @@
 use strict;
 use warnings;
 
-use Test::More tests => 7;
+use Test::More tests => 8;
 
 BEGIN
 {
-    use_ok('DateTime::Format::Natural');
-    use_ok('DateTime::Format::Natural::Base');
-    use_ok('DateTime::Format::Natural::Compat');
-    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');
+    my @modules = qw(
+        DateTime::Format::Natural
+        DateTime::Format::Natural::Base
+        DateTime::Format::Natural::Compat
+        DateTime::Format::Natural::Duration
+        DateTime::Format::Natural::Helpers
+        DateTime::Format::Natural::Lang::Base
+        DateTime::Format::Natural::Lang::EN
+        DateTime::Format::Natural::Test
+    );
+    use_ok($_) foreach @modules;
 }

Modified: branches/upstream/libdatetime-format-natural-perl/current/t/01-parse.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/01-parse.t?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/01-parse.t (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/01-parse.t Sat Sep 19 23:06:09 2009
@@ -247,10 +247,8 @@
 
     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, _message($string));
+        is(_result_string($dt), $result, _message($string));
     }
     else {
         fail(_message($string));

Modified: branches/upstream/libdatetime-format-natural-perl/current/t/02-parse_format.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/02-parse_format.t?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/02-parse_format.t (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/02-parse_format.t Sat Sep 19 23:06:09 2009
@@ -35,10 +35,8 @@
 
     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, _message($string));
+        is(_result_string($dt), $result, _message($string));
     }
     else {
         fail(_message($string));

Modified: branches/upstream/libdatetime-format-natural-perl/current/t/03-parse_daytime.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/03-parse_daytime.t?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/03-parse_daytime.t (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/03-parse_daytime.t Sat Sep 19 23:06:09 2009
@@ -45,10 +45,8 @@
 
     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, _message($string));
+        is(_result_string($dt), $result, _message($string));
     }
     else {
         fail(_message($string));

Modified: branches/upstream/libdatetime-format-natural-perl/current/t/04-parse_durations.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/04-parse_durations.t?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/04-parse_durations.t (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/04-parse_durations.t Sat Sep 19 23:06:09 2009
@@ -14,6 +14,13 @@
     { '1999 to 2006'     => [ '01.01.1999 00:00:00', '01.01.2006 00:00:00' ] },
 );
 
+my @combined = (
+    { 'first day of 2009 to last day of 2009' => [ '01.01.2009 00:00:00', '31.12.2009 00:00:00' ] },
+    { 'first day of may to last day of may'   => [ '01.05.2006 00:00:00', '31.05.2006 00:00:00' ] },
+    { 'first to last day of 2008'             => [ '01.01.2008 00:00:00', '31.12.2008 00:00:00' ] },
+    { 'first to last day of september'        => [ '01.09.2006 00:00:00', '30.09.2006 00:00:00' ] },
+);
+
 my @relative = (
     { '2009-03-10 9:00 to 11:00' => [ '10.03.2009 09:00:00', '10.03.2009 11:00:00' ] },
     { 'for 4 seconds'            => [ '24.11.2006 01:13:08', '24.11.2006 01:13:12' ] },
@@ -25,7 +32,7 @@
     { 'for 4 years'              => [ '24.11.2006 01:13:08', '24.11.2010 01:13:08' ] },
 );
 
-_run_tests(11, [ [ \@absolute ], [ \@relative ] ], \&compare);
+_run_tests(15, [ [ \@absolute ], [ \@combined ], [ \@relative ] ], \&compare);
 
 sub compare
 {
@@ -47,8 +54,7 @@
 
     my $pass = true;
     foreach my $i (0..$#dt) {
-        my $res_string = sprintf('%02d.%02d.%4d %02d:%02d:%02d', $dt[$i]->day, $dt[$i]->month, $dt[$i]->year, $dt[$i]->hour, $dt[$i]->min, $dt[$i]->sec);
-        $pass &= $res_string eq $result->[$i];
+        $pass &= _result_string($dt[$i]) eq $result->[$i];
     }
 
     if ($parser->success && $pass && scalar @dt == 2) {

Modified: branches/upstream/libdatetime-format-natural-perl/current/t/05-parse_time_zone.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/05-parse_time_zone.t?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/05-parse_time_zone.t (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/05-parse_time_zone.t Sat Sep 19 23:06:09 2009
@@ -96,10 +96,8 @@
 
     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, _message($string));
+        is(_result_string($dt), $result, _message($string));
     }
     else {
         fail(_message($string));

Modified: branches/upstream/libdatetime-format-natural-perl/current/t/06-parse_prefer_future.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/06-parse_prefer_future.t?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/06-parse_prefer_future.t (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/06-parse_prefer_future.t Sat Sep 19 23:06:09 2009
@@ -63,10 +63,8 @@
     my $parser = DateTime::Format::Natural->new(prefer_future => true);
     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, _message($string));
+        is(_result_string($dt), $result, _message($string));
     }
     else {
         fail(_message($string));

Modified: branches/upstream/libdatetime-format-natural-perl/current/t/07-parse_datetime.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/07-parse_datetime.t?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/07-parse_datetime.t (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/07-parse_datetime.t Sat Sep 19 23:06:09 2009
@@ -29,10 +29,8 @@
     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, _message($string));
+        is(_result_string($dt), $result, _message($string));
     }
     else {
         fail(_message($string));

Modified: branches/upstream/libdatetime-format-natural-perl/current/t/09-regression.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/09-regression.t?rev=44363&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/09-regression.t (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/09-regression.t Sat Sep 19 23:06:09 2009
@@ -5,7 +5,7 @@
 
 use Test::MockTime qw(set_fixed_time);
 use DateTime::Format::Natural;
-use Test::More tests => 1;
+use Test::More tests => 2;
 
 {
     local $@;
@@ -14,4 +14,10 @@
         DateTime::Format::Natural->new->parse_datetime('april 3');
     };
     ok(!$@, 'units set at once');
+
+    # rt #49326
+    set_fixed_time('31.08.2009', '%d.%m.%Y');
+    my $parser = DateTime::Format::Natural->new;
+    $parser->parse_datetime('30/11/2009');
+    ok($parser->success, '_check_date() sets at once');
 }

Added: branches/upstream/libdatetime-format-natural-perl/current/t/10-state.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/10-state.t?rev=44363&op=file
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/10-state.t (added)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/10-state.t Sat Sep 19 23:06:09 2009
@@ -1,0 +1,16 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use DateTime::Format::Natural;
+use Test::More tests => 1;
+
+{
+    # Expected to fail with first parse ('31/09/2009'), because
+    # parse_datetime_duration() retains the first failing state.
+    my $string = '31/09/2009 to 31/10/2009';
+    my $parser = DateTime::Format::Natural->new;
+    $parser->parse_datetime_duration($string);
+    ok(!$parser->success && defined $parser->error, $string);
+}

Propchange: branches/upstream/libdatetime-format-natural-perl/current/t/10-state.t
------------------------------------------------------------------------------
    svn:executable = *




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