r59464 - 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
Thu Jun 17 05:20:29 UTC 2010


Author: carnil-guest
Date: Thu Jun 17 05:19:46 2010
New Revision: 59464

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

Added:
    branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Calc.pm
    branches/upstream/libdatetime-format-natural-perl/current/t/10-parse_assert.t   (with props)
    branches/upstream/libdatetime-format-natural-perl/current/t/11-regression.t   (with props)
    branches/upstream/libdatetime-format-natural-perl/current/t/12-state.t   (with props)
    branches/upstream/libdatetime-format-natural-perl/current/t/13-trace.t   (with props)
Removed:
    branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Base.pm
    branches/upstream/libdatetime-format-natural-perl/current/t/10-regression.t
    branches/upstream/libdatetime-format-natural-perl/current/t/11-state.t
    branches/upstream/libdatetime-format-natural-perl/current/t/12-trace.t
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/Lang/EN.pm
    branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse
    branches/upstream/libdatetime-format-natural-perl/current/t/00-load.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=59464&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/Changes (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/Changes Thu Jun 17 05:19:46 2010
@@ -1,4 +1,40 @@
 Revision history for Perl extension DateTime::Format::Natural.
+
+0.88  2010-06-16  <schubiger at cpan.org>
+
+ - Merged development version to stable.
+
+0.87_03  2010-06-12  <schubiger at cpan.org>
+
+ - Fix broken use_ok() test for the Calc module.
+
+ - Insert some missing examples in the grammar documentation.
+
+0.87_02  2010-06-09  <schubiger at cpan.org>
+
+ - Strengthen the check for invalid units of prefixed dates.
+
+ - Add a test file for parse asserts.
+
+ - Rename Base.pm to Calc.pm and adjust trace tests.
+
+ - Reword the according abstract and description.
+
+ - Document where arguments to dateparse's switches are required.
+
+ - Allow dateparse to handle the language code in uppercase.
+
+0.87_01  2010-06-06  <schubiger at cpan.org>
+
+ - Match case-insensitively in the language option check.
+
+ - Require (and not use) the grammar class in runtime eval.
+
+ - Purge the remains of the formatted instance data member.
+
+ - Delete some instance data through hash slices.
+
+ - Convert a few non-option identifiers to lowercase.
 
 0.87  2010-05-29  <schubiger at cpan.org>
 

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=59464&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/MANIFEST (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/MANIFEST Thu Jun 17 05:19:46 2010
@@ -3,7 +3,7 @@
 INSTALL
 lib/DateTime/Format/Natural.pm
 lib/DateTime/Format/Natural/Aliases.pm
-lib/DateTime/Format/Natural/Base.pm
+lib/DateTime/Format/Natural/Calc.pm
 lib/DateTime/Format/Natural/Compat.pm
 lib/DateTime/Format/Natural/Duration.pm
 lib/DateTime/Format/Natural/Formatted.pm
@@ -28,8 +28,9 @@
 t/07-parse_datetime.t
 t/08-parse_failure.t
 t/09-parse_aliases.t
-t/10-regression.t
-t/11-state.t
-t/12-trace.t
+t/10-parse_assert.t
+t/11-regression.t
+t/12-state.t
+t/13-trace.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=59464&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/META.yml (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/META.yml Thu Jun 17 05:19:46 2010
@@ -1,6 +1,6 @@
 ---
 name: DateTime-Format-Natural
-version: 0.87
+version: 0.88
 author:
   - 'Steven Schubiger <schubiger at cpan.org>'
 abstract: Create machine readable date/time with natural parsing logic
@@ -29,13 +29,13 @@
 provides:
   DateTime::Format::Natural:
     file: lib/DateTime/Format/Natural.pm
-    version: 0.87
+    version: 0.88
   DateTime::Format::Natural::Aliases:
     file: lib/DateTime/Format/Natural/Aliases.pm
     version: 0.03
-  DateTime::Format::Natural::Base:
-    file: lib/DateTime/Format/Natural/Base.pm
-    version: 1.33
+  DateTime::Format::Natural::Calc:
+    file: lib/DateTime/Format/Natural/Calc.pm
+    version: 1.34
   DateTime::Format::Natural::Compat:
     file: lib/DateTime/Format/Natural/Compat.pm
     version: 0.07
@@ -53,7 +53,7 @@
     version: 1.06
   DateTime::Format::Natural::Lang::EN:
     file: lib/DateTime/Format/Natural/Lang/EN.pm
-    version: 1.36
+    version: 1.37
   DateTime::Format::Natural::Test:
     file: lib/DateTime/Format/Natural/Test.pm
     version: 0.05

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=59464&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 Thu Jun 17 05:19:46 2010
@@ -4,7 +4,7 @@
 use warnings;
 use base qw(
     DateTime::Format::Natural::Aliases
-    DateTime::Format::Natural::Base
+    DateTime::Format::Natural::Calc
     DateTime::Format::Natural::Duration
     DateTime::Format::Natural::Formatted
     DateTime::Format::Natural::Helpers
@@ -18,7 +18,7 @@
 use Scalar::Util qw(blessed);
 use Storable qw(dclone);
 
-our $VERSION = '0.87';
+our $VERSION = '0.88';
 
 validation_options(
     on_fail => sub
@@ -64,7 +64,7 @@
     $self->{Daytime} = $opts{daytime} || {};
 
     my $mod = __PACKAGE__.'::Lang::'.uc($self->{Lang});
-    eval "use $mod"; die $@ if $@;
+    eval "require $mod"; die $@ if $@;
 
     $self->{data} = $mod->__new();
     $self->{grammar_class} = $mod;
@@ -78,7 +78,7 @@
         lang => {
             type => SCALAR,
             optional => true,
-            regex => qr!^(?:en)$!,
+            regex => qr!^(?:en)$!i,
         },
         format => {
             type => SCALAR,
@@ -123,9 +123,7 @@
 {
     my $self = shift;
 
-    foreach my $member (qw(modified postprocess)) {
-        delete $self->{$member};
-    }
+    delete @$self{qw(modified postprocess)};
 }
 
 sub parse_datetime
@@ -134,9 +132,9 @@
 
     $self->_parse_init(@_);
 
-    $self->{Input_string} = $self->{Date_string};
-
-    my $date_string = $self->{Date_string};
+    $self->{input_string} = $self->{date_string};
+
+    my $date_string = $self->{date_string};
 
     $self->_rewrite_aliases(\$date_string);
     $date_string =~ tr/,//d;
@@ -173,7 +171,7 @@
         );
         my $method = $methods{$prefix};
 
-        if (none { $unit =~ /${_}s?/ } @{$self->{data}->__units('ordered')}) {
+        if (none { $unit =~ /^${_}s?$/ } @{$self->{data}->__units('ordered')}) {
             $self->_set_failure;
             $self->_set_error("(invalid unit)");
             return $self->_get_datetime_object;
@@ -220,7 +218,7 @@
 {
     my $self = shift;
 
-    $self->_params_init(@_, { string => \$self->{Date_string} });
+    $self->_params_init(@_, { string => \$self->{date_string} });
 
     my $set_datetime = sub
     {
@@ -285,12 +283,10 @@
     $self->_post_duration(\@queue);
     $self->_restore_state;
 
-    foreach my $member (qw(duration formatted insert state)) {
-        delete $self->{$member};
-    }
+    delete @$self{qw(duration insert state)};
 
     @{$self->{traces}} = @traces;
-    $self->{Input_string} = $duration_string;
+    $self->{input_string} = $duration_string;
 
     return @queue;
 }
@@ -308,7 +304,7 @@
 
     return '' if $self->success;
 
-    my $error  = "'$self->{Input_string}' does not parse ";
+    my $error  = "'$self->{input_string}' does not parse ";
        $error .= $self->_get_error || '(perhaps you have some garbage?)';
 
     return $error;

Added: branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Calc.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Calc.pm?rev=59464&op=file
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Calc.pm (added)
+++ branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Calc.pm Thu Jun 17 05:19:46 2010
@@ -1,0 +1,468 @@
+package DateTime::Format::Natural::Calc;
+
+use strict;
+use warnings;
+use base qw(
+    DateTime::Format::Natural::Compat
+    DateTime::Format::Natural::Utils
+    DateTime::Format::Natural::Wrappers
+);
+
+our $VERSION = '1.34';
+
+use constant MORNING   => '08';
+use constant AFTERNOON => '14';
+use constant EVENING   => '20';
+
+sub _no_op
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+}
+
+sub _ago_variant
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    $self->_subtract($opts->{unit} => shift);
+}
+
+sub _now_variant
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($value, $when) = @_;
+    $self->_add_or_subtract({
+        when  => $when,
+        unit  => $opts->{unit},
+        value => $value,
+    });
+}
+
+sub _daytime_in_the_variant
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($hour) = @_;
+    $hour += $opts->{hours} || 0;
+    if ($self->_valid_time(hour => $hour)) {
+        $self->_set(
+            hour   => $hour,
+            minute => 0,
+            second => 0,
+        );
+    }
+}
+
+sub _daytime_variant
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($daytime) = @_;
+    my %lookup = (
+        0 => 'morning',
+        1 => 'afternoon',
+        2 => 'evening',
+    );
+    $daytime = $lookup{$daytime};
+    my %daytimes = (
+        morning   => MORNING,
+        afternoon => AFTERNOON,
+        evening   => EVENING,
+    );
+    my $hour = $self->{Daytime}{$daytime}
+      ? $self->{Daytime}{$daytime}
+      : $daytimes{$daytime};
+    if ($self->_valid_time(hour => $hour)) {
+        $self->_set(
+            hour   => $hour,
+            minute => 0,
+            second => 0,
+        );
+    }
+}
+
+sub _daytime
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($hour) = @_;
+    if ($self->_valid_time(hour => $hour)) {
+        $self->_set(
+            hour   => $hour,
+            minute => 0,
+            second => 0,
+        );
+    }
+}
+
+sub _hourtime_variant
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    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 => $value,
+        });
+    }
+}
+
+sub _month_day
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($day, $month) = @_;
+    if ($self->_valid_date(month => $month, day => $day)) {
+        $self->_set(
+            month => $month,
+            day   => $day,
+        );
+    }
+}
+
+sub _unit_date
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($value) = @_;
+    if ($self->_valid_date($opts->{unit} => $value)) {
+        $self->_set($opts->{unit} => $value);
+    }
+}
+
+sub _weekday
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($day) = @_;
+    if ($day > $self->{datetime}->wday) {
+        $self->_add(day => ($day - $self->{datetime}->wday));
+    }
+    else {
+        $self->_subtract(day => ($self->{datetime}->wday - $day));
+    }
+}
+
+sub _count_day_variant_week
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($when, $day) = @_;
+    my %days = (
+        -1 => ($self->{datetime}->wday + (7 - $day)),
+         0 => ($day - $self->{datetime}->wday),
+         1 => (7 - $self->{datetime}->wday + $day),
+    );
+    $self->_add_or_subtract({
+        when  => ($when == 0) ? 1 : $when,
+        unit  => 'day',
+        value => $days{$when},
+    });
+}
+
+sub _count_day_variant_month
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($when, $day) = @_;
+    if ($self->_valid_date(day => $day)) {
+        $self->_add(month => $when);
+        $self->_set(day => $day);
+    }
+}
+
+sub _unit_variant
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($when) = @_;
+    $self->_add_or_subtract({
+        when  => $when,
+        unit  => $opts->{unit},
+        value => 1,
+    });
+}
+
+sub _count_month_variant_year
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($when, $month) = @_;
+    if ($self->_valid_date(month => $month)) {
+        $self->_add(year => $when);
+        $self->_set(month => $month);
+    }
+}
+
+sub _in_count_variant
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    $self->_add_or_subtract($opts->{unit} => shift);
+}
+
+sub _month_variant
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($when, $month) = @_;
+    if ($self->_valid_date(month => $month)) {
+        $self->_add(year => $when);
+        $self->_set(month => $month);
+    }
+}
+
+sub _count_weekday_variant_month
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($when, $count, $day, $month) = @_;
+    my $year;
+    local $@;
+    eval {
+        ($year, $month, $day) =
+          $self->_Nth_Weekday_of_Month_Year(
+              $self->{datetime}->year + $when,
+              defined $month
+                ? $month
+                : $self->{datetime}->month,
+              $day,
+              $count,
+          );
+    };
+    if (!$@ and defined $year && defined $month && defined $day
+        and $self->_valid_date(year => $year, month => $month, day => $day))
+    {
+        $self->_set(
+            year  => $year,
+            month => $month,
+            day   => $day,
+        );
+    }
+    else {
+        $self->_set_failure;
+        $self->_set_error("(date is not valid)");
+    }
+}
+
+sub _daytime_hours_variant
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($hours, $when, $days) = @_;
+    my %values = (
+        -1 => { day => ($days - 1), hours => (24 - $hours) },
+         1 => { day => $days,       hours => (0  + $hours) },
+    );
+    if ($self->_valid_time(hour => $values{$when}->{hours})) {
+        $self->_add(day => $values{$when}->{day});
+        $self->_set(hour => $values{$when}->{hours});
+    }
+}
+
+# wrapper for <time> AM/PM
+sub _at
+{
+    my $self = shift;
+    $self->_register_trace;
+    $self->_at_time(@_);
+}
+
+# wrapper for <time>
+sub _time
+{
+    my $self = shift;
+    $self->_register_trace;
+    $self->_at_time(@_);
+}
+
+sub _at_time
+{
+    my $self = shift;
+    my $opts = pop;
+    my ($time) = @_;
+    if ($time =~ /:/) {
+        my ($hour, $minute) = split /:/, $time;
+        if ($self->_valid_time(hour => $hour, minute => $minute)) {
+            $self->_set(
+                hour   => $hour,
+                minute => $minute,
+            );
+        }
+    }
+    else {
+        if ($self->_valid_time(hour => $time)) {
+            $self->_set(
+                hour   => $time,
+                minute => 0,
+            );
+        }
+    }
+}
+
+sub _time_full
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($time) = @_;
+    my ($hour, $minute, $second) = split /:/, $time;
+    if ($self->_valid_time(hour => $hour, minute => $minute, second => $second)) {
+        $self->_set(
+            hour   => $hour,
+            minute => $minute,
+            second => $second,
+        );
+    }
+}
+
+sub _count_yearday_variant_year
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($day, $when) = @_;
+    my ($year, $month);
+    ($year, $month, $day) = $self->_Add_Delta_Days($self->{datetime}->year, $day);
+    $self->_set(
+        year  => $year + $when,
+        month => $month,
+        day   => $day,
+    );
+}
+
+sub _count_weekday
+{
+    my $self = shift;
+    $self->_count_weekday_variant_month(0, @_[0,1], undef, $_[-1]);
+}
+
+sub _day_month_year
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($day, $month, $year) = @_;
+    if ($self->_valid_date(year => $year, month => $month, day => $day)) {
+        $self->_set(
+            year  => $year,
+            month => $month,
+            day   => $day,
+        );
+    }
+}
+
+sub _count_weekday_from_now
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($count, $day) = @_;
+    my $wday = $self->{datetime}->wday;
+    $self->_add(day => ($count - 1) * 7 +
+        (($wday < $day)
+          ? $day - $wday
+          : (7 - $wday) + $day)
+    );
+}
+
+sub _final_weekday_in_month
+{
+    my $self = shift;
+    $self->_register_trace;
+    my $opts = pop;
+    my ($wday, $month) = @_;
+    my $days = $self->_Days_in_Month($self->{datetime}->year, $month);
+    my ($year, $day);
+    ($year, $month, $day) = $self->_Nth_Weekday_of_Month_Year(
+        $self->{datetime}->year,
+        $month,
+        $wday,
+        1,
+    );
+    while ($day <= $days - 7) {
+        $day += 7;
+    }
+    $self->_set(
+        year  => $year,
+        month => $month,
+        day   => $day,
+    );
+}
+
+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__
+
+=head1 NAME
+
+DateTime::Format::Natural::Calc - Basic calculations
+
+=head1 SYNOPSIS
+
+ Please see the DateTime::Format::Natural documentation.
+
+=head1 DESCRIPTION
+
+The C<DateTime::Format::Natural::Calc> class defines the worker methods.
+
+=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://dev.perl.org/licenses/>
+
+=cut

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=59464&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 Thu Jun 17 05:19:46 2010
@@ -9,7 +9,7 @@
 
 use DateTime::Format::Natural::Helpers qw(%flag);
 
-our $VERSION = '1.36';
+our $VERSION = '1.37';
 
 our (%init,
      %timespan,
@@ -3906,6 +3906,9 @@
  tomorrow morning
  tomorrow afternoon
  tomorrow evening
+ 6:00 yesterday
+ 6:00 today
+ 6:00 tomorrow
  5am yesterday
  5am today
  5am tomorrow
@@ -3961,6 +3964,9 @@
  yesterday at 4:00
  today at 4:00
  tomorrow at 4:00
+ yesterday at 6:45am
+ today at 6:45am
+ tomorrow at 6:45am
  yesterday at 6:45pm
  today at 6:45pm
  tomorrow at 6:45pm
@@ -3970,6 +3976,9 @@
  yesterday at 2:32 PM
  today at 2:32 PM
  tomorrow at 2:32 PM
+ yesterday 02:32
+ today 02:32
+ tomorrow 02:32
  yesterday 2:32am
  today 2:32am
  tomorrow 2:32am
@@ -3977,8 +3986,10 @@
  today 2:32pm
  tomorrow 2:32pm
  wednesday at 14:30
+ wednesday at 02:30am
  wednesday at 02:30pm
  wednesday 14:30
+ wednesday 02:30am
  wednesday 02:30pm
  friday 03:00 am
  friday 03:00 pm
@@ -3999,10 +4010,14 @@
  06:56:06 am
  06:56:06 pm
  mon 2:35
+ 1:00 sun
  1am sun
  1pm sun
+ 1:00 on sun
  1am on sun
  1pm on sun
+ 12:14 PM
+ 12:14 AM
 
 =head2 Complex
 
@@ -4074,6 +4089,9 @@
  last friday at 20:00
  this friday at 20:00
  next friday at 20:00
+ 1:00 last friday
+ 1:00 this friday
+ 1:00 next friday
  1am last friday
  1am this friday
  1am next friday
@@ -4086,6 +4104,8 @@
  2nd friday in august
  3rd wednesday in november
  tomorrow 1 year ago
+ saturday 3 months ago at 17:00
+ saturday 3 months ago at 5:00am
  saturday 3 months ago at 5:00pm
  11 january 2 years ago
  4th day last week
@@ -4100,7 +4120,7 @@
 
 =head2 Timespans
 
- Monday to Friday
+ monday to friday
  1 April to 31 August
  1999-12-31 to tomorrow
  now to 2010-01-01
@@ -4123,9 +4143,10 @@
 =head2 Specific
 
  march
- January 11
- 11 January
+ january 11
+ 11 january
  dec 25
+ feb 28 3:00
  feb 28 3am
  feb 28 3pm
  may 27th

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=59464&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse Thu Jun 17 05:19:46 2010
@@ -67,14 +67,14 @@
 {
     print <<USAGE;
 Usage: $0 [switches]
-  -f, --format           format of numeric dates
-  -h, --help             this help screen
-  -l, --lang             language code
-  -p, --prefer_future    use future dates (when possible)
-  -s, --supported        list of supported languages
-  -t, --time_zone        time zone string
-  -T, --trace            print trace after processing
-  -V, --version          print version
+   -f, --format=<format>       format of numeric dates
+   -h, --help                  this help screen
+   -l, --lang=<code>           language code
+   -p, --prefer_future         use future dates (when possible)
+   -s, --supported             list of supported languages
+   -t, --time_zone=<string>    time zone string
+   -T, --trace                 print trace after processing
+   -V, --version               print version
 USAGE
     exit;
 }
@@ -93,7 +93,7 @@
 
 sub process
 {
-    unless ($valid_languages{$lang}) {
+    unless ($valid_languages{lc $lang}) {
         warn "Language [$lang] isn't supported, switching to default [", LANG_DEFAULT, "]\n";
         $lang = $args{lang} = LANG_DEFAULT;
     }
@@ -143,14 +143,14 @@
 =head1 SYNOPSIS
 
  Usage: dateparse [switches]
-   -f, --format           format of numeric dates
-   -h, --help             this help screen
-   -l, --lang             language code
-   -p, --prefer_future    use future dates (when possible)
-   -s, --supported        list of supported languages
-   -t, --time_zone        time zone string
-   -T, --trace            print trace after processing
-   -V, --version          print version
+   -f, --format=<format>       format of numeric dates
+   -h, --help                  this help screen
+   -l, --lang=<code>           language code
+   -p, --prefer_future         use future dates (when possible)
+   -s, --supported             list of supported languages
+   -t, --time_zone=<string>    time zone string
+   -T, --trace                 print trace after processing
+   -V, --version               print version
 
 =head1 AUTHOR
 

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=59464&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 Thu Jun 17 05:19:46 2010
@@ -10,7 +10,7 @@
     my @modules = qw(
         DateTime::Format::Natural
         DateTime::Format::Natural::Aliases
-        DateTime::Format::Natural::Base
+        DateTime::Format::Natural::Calc
         DateTime::Format::Natural::Compat
         DateTime::Format::Natural::Duration
         DateTime::Format::Natural::Formatted

Added: branches/upstream/libdatetime-format-natural-perl/current/t/10-parse_assert.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/10-parse_assert.t?rev=59464&op=file
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/10-parse_assert.t (added)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/10-parse_assert.t Thu Jun 17 05:19:46 2010
@@ -1,0 +1,19 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use DateTime::Format::Natural;
+use Test::More tests => 1;
+
+{
+    # Assert for prefixed dates that an extracted unit which is
+    # partially invalid is not being passed to a DateTime wrapper.
+    local $@;
+    eval {
+        my $parser = DateTime::Format::Natural->new;
+        $parser->parse_datetime('+1XXXday');
+        $parser->parse_datetime('-1dayXXX');
+    };
+    ok(!$@, 'prefixed date');
+}

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

Added: branches/upstream/libdatetime-format-natural-perl/current/t/11-regression.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/11-regression.t?rev=59464&op=file
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/11-regression.t (added)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/11-regression.t Thu Jun 17 05:19:46 2010
@@ -1,0 +1,23 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::MockTime qw(set_fixed_time);
+use DateTime::Format::Natural;
+use Test::More tests => 2;
+
+{
+    local $@;
+    eval {
+        set_fixed_time('31.03.2009 04:32:22', '%d.%m.%Y %H:%M:%S');
+        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');
+}

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

Added: branches/upstream/libdatetime-format-natural-perl/current/t/12-state.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/12-state.t?rev=59464&op=file
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/12-state.t (added)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/12-state.t Thu Jun 17 05:19:46 2010
@@ -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/12-state.t
------------------------------------------------------------------------------
    svn:executable = *

Added: branches/upstream/libdatetime-format-natural-perl/current/t/13-trace.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/13-trace.t?rev=59464&op=file
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/13-trace.t (added)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/13-trace.t Thu Jun 17 05:19:46 2010
@@ -1,0 +1,50 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use DateTime::Format::Natural;
+use Test::More tests => 5;
+
+my $parser = DateTime::Format::Natural->new;
+my $stringify = sub { local $" = "\n"; "@_\n" };
+
+{
+    my $string;
+
+    $string = 'now';
+    $parser->parse_datetime($string);
+    is($stringify->(($parser->trace)[0]), <<'EOT', $string);
+DateTime::Format::Natural::Calc::_no_op
+EOT
+    $string = 'yesterday 3 years ago';
+    $parser->parse_datetime($string);
+    is($stringify->(($parser->trace)[0]), <<'EOT', $string);
+DateTime::Format::Natural::Calc::_unit_variant
+DateTime::Format::Natural::Calc::_ago_variant
+day: 1
+year: 1
+EOT
+    $string = 'monday to friday';
+    $parser->parse_datetime_duration($string);
+    is($stringify->($parser->trace), <<'EOT', $string);
+DateTime::Format::Natural::Calc::_weekday
+day: 1
+DateTime::Format::Natural::Calc::_weekday
+day: 1
+EOT
+}
+
+{
+    my ($string, @trace);
+
+    $string = 'bogus';
+    $parser->parse_datetime($string);
+    @trace = $parser->trace;
+    ok(!@trace, 'empty trace for parse_datetime');
+
+    $string = 'bogus to bogus';
+    $parser->parse_datetime_duration($string);
+    @trace = $parser->trace;
+    ok(!@trace, 'empty trace for parse_datetime_duration');
+}

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




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