r24427 - in /branches/upstream/libdatetime-format-natural-perl/current: Changes META.yml lib/DateTime/Format/Natural.pm lib/DateTime/Format/Natural/Base.pm lib/DateTime/Format/Natural/Lang/Base.pm scripts/dateparse

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Thu Aug 21 01:04:54 UTC 2008


Author: ansgar-guest
Date: Thu Aug 21 01:04:48 2008
New Revision: 24427

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

Modified:
    branches/upstream/libdatetime-format-natural-perl/current/Changes
    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/Lang/Base.pm
    branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse

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=24427&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/Changes (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/Changes Thu Aug 21 01:04:48 2008
@@ -1,4 +1,32 @@
 Revision history for Perl extension DateTime::Format::Natural.
+
+0.72 Sat Aug 16 13:39:27 CEST 2008
+
+ - When referring within classes to themselves, use the proper
+   term "class" instead of "module".
+
+ - Merged development version to stable.
+
+0.71_04 Thu Aug  7 11:28:36 CEST 2008
+
+ - Call validation_options() when DateTime::Format::Natural
+   gets loaded (instead of relying on it to be called from
+   within a method).
+
+0.71_03 Sun Aug  3 11:06:09 CEST 2008
+
+ - Declared some more expected types when validating arguments
+   with Params::Validate.
+
+0.71_02 Fri Aug  1 13:54:02 CEST 2008
+
+ - Moved some duplicated code fragments within the main base class
+   to separate methods.
+
+0.71_01 Wed Jul 30 22:15:49 CEST 2008
+
+ - Added time_zone parameter support to 'dateparse' and a shortcut
+   to leave it quickly.
 
 0.71 Thu Jun 12 11:17:22 CEST 2008
 

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=24427&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/META.yml (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/META.yml Thu Aug 21 01:04:48 2008
@@ -1,6 +1,6 @@
 ---
 name: DateTime-Format-Natural
-version: 0.71
+version: 0.72
 author:
   - 'Steven Schubiger <schubiger at cpan.org>'
 abstract: Create machine readable date/time with natural parsing logic
@@ -22,13 +22,13 @@
 provides:
   DateTime::Format::Natural:
     file: lib/DateTime/Format/Natural.pm
-    version: 0.71
+    version: 0.72
   DateTime::Format::Natural::Base:
     file: lib/DateTime/Format/Natural/Base.pm
-    version: 1.11
+    version: 1.13
   DateTime::Format::Natural::Lang::Base:
     file: lib/DateTime/Format/Natural/Lang/Base.pm
-    version: 0.8
+    version: 0.9
   DateTime::Format::Natural::Lang::EN:
     file: lib/DateTime/Format/Natural/Lang/EN.pm
     version: 1.11

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=24427&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 Aug 21 01:04:48 2008
@@ -10,7 +10,17 @@
 use List::MoreUtils qw(all any);
 use Params::Validate ':all';
 
-our $VERSION = '0.71';
+our $VERSION = '0.72';
+
+validation_options(
+    on_fail => sub
+{
+    my ($error) = @_;
+    chomp $error;
+    croak $error;
+},
+    stack_skip => 2,
+);
 
 sub new
 {
@@ -44,16 +54,6 @@
 sub _init_check
 {
     my $self = shift;
-
-    validation_options(
-        on_fail => sub
-    {
-        my ($error) = @_;
-        chomp $error;
-        croak $error;
-    },
-        stack_skip => 2,
-    );
 
     validate(@_, {
         lang => {
@@ -193,13 +193,13 @@
     my $self = shift;
 
     if (@_ > 1) {
-        validate(@_, { string => 1 });
+        validate(@_, { string => { type => SCALAR }});
         my %opts             = @_;
         $self->{Date_string} = $opts{string};
         (undef)              = $opts{debug}; # legacy
     }
     else {
-        validate_pos(@_, 1);
+        validate_pos(@_, { type => SCALAR });
         ($self->{Date_string}) = @_;
     }
 

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=24427&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 Thu Aug 21 01:04:48 2008
@@ -3,13 +3,12 @@
 use strict;
 use warnings;
 
-use DateTime ();
 use Date::Calc qw(Add_Delta_Days
                   Decode_Day_of_Week
                   Nth_Weekday_of_Month_Year
                   check_date check_time);
 
-our $VERSION = '1.11';
+our $VERSION = '1.13';
 
 use constant MORNING   => '08';
 use constant AFTERNOON => '14';
@@ -350,11 +349,7 @@
     my $self = shift;
     $self->_add_trace;
     my ($month) = @_;
-    $month = ucfirst lc $month;
-    if (length $month == 3) {
-        $month = $self->{data}->{months_abbrev}->{$month};
-    }
-    $self->_set(month => $self->{data}->{months}->{$month});
+    $self->_set(month => $self->_month_num($month));
     $self->_set_modified(1);
 }
 
@@ -363,11 +358,7 @@
     my $self = shift;
     $self->_add_trace;
     my ($month, $day) = @_;
-    $month = ucfirst lc $month;
-    if (length $month == 3) {
-        $month = $self->{data}->{months_abbrev}->{$month};
-    }
-    $self->_set(month => $self->{data}->{months}->{$month});
+    $self->_set(month => $self->_month_num($month));
     if ($self->_valid_date(day => $day)) {
         $self->_set(day => $day);
     }
@@ -379,11 +370,7 @@
     my $self = shift;
     $self->_add_trace;
     my ($day, $month) = @_;
-    $month = ucfirst lc $month;
-    if (length $month == 3) {
-        $month = $self->{data}->{months_abbrev}->{$month};
-    }
-    $self->_set(month => $self->{data}->{months}->{$month});
+    $self->_set(month => $self->_month_num($month));
     if ($self->_valid_date(day => $day)) {
         $self->_set(day => $day);
     }
@@ -406,10 +393,7 @@
     my $self = shift;
     $self->_add_trace;
     my ($day) = @_;
-    $day = ucfirst lc $day;
-    if (length $day == 3) {
-        $day = $self->{data}->{weekdays_abbrev}->{$day};
-    }
+    $self->_day_name(\$day);
     my $days_diff;
     # Set current weekday by adding the day difference
     if ($self->{data}->{weekdays}->{$day} > $self->{datetime}->wday) {
@@ -429,10 +413,7 @@
     my $self = shift;
     $self->_add_trace;
     my ($day) = @_;
-    $day = ucfirst lc $day;
-    if (length $day == 3) {
-        $day = $self->{data}->{weekdays_abbrev}->{$day};
-    }
+    $self->_day_name(\$day);
     my $days_diff = $self->{datetime}->wday + (7 - $self->{data}->{weekdays}->{$day});
     $self->_subtract(day => $days_diff);
     $self->_set_modified(2);
@@ -482,12 +463,8 @@
     my $self = shift;
     $self->_add_trace;
     my ($month) = @_;
-    $month = ucfirst lc $month;
-    if (length $month == 3) {
-        $month = $self->{data}->{months_abbrev}->{$month};
-    }
     $self->_subtract(year => 1);
-    $self->_set(month => $self->{data}->{months}->{$month});
+    $self->_set(month => $self->_month_num($month));
     $self->_set_modified(4);
 }
 
@@ -522,10 +499,7 @@
     my $self = shift;
     $self->_add_trace;
     my ($day) = @_;
-    $day = ucfirst lc $day;
-    if (length $day == 3) {
-        $day = $self->{data}->{weekdays_abbrev}->{$day};
-    }
+    $self->_day_name(\$day);
     my $days_diff = (7 - $self->{datetime}->wday + Decode_Day_of_Week($day));
     $self->_add(day => $days_diff);
     $self->_set_modified(2);
@@ -536,10 +510,7 @@
     my $self = shift;
     $self->_add_trace;
     my ($day) = @_;
-    $day = ucfirst lc $day;
-    if (length $day == 3) {
-        $day = $self->{data}->{weekdays_abbrev}->{$day};
-    }
+    $self->_day_name(\$day);
     my $days_diff = (7 - $self->{datetime}->wday + Decode_Day_of_Week($day));
     $self->_add(day => $days_diff);
     $self->_set_modified(3);
@@ -550,12 +521,8 @@
     my $self = shift;
     $self->_add_trace;
     my ($month) = @_;
-    $month = ucfirst lc $month;
-    if (length $month == 3) {
-        $month = $self->{data}->{months_abbrev}->{$month};
-    }
     $self->_add(year => 1);
-    $self->_set(month => $self->{data}->{months}->{$month});
+    $self->_set(month => $self->_month_num($month));
     $self->_set_modified(2);
 }
 
@@ -634,10 +601,7 @@
     my $self = shift;
     $self->_add_trace;
     my ($day) = @_;
-    $day = ucfirst lc $day;
-    if (length $day == 3) {
-        $day = $self->{data}->{weekdays_abbrev}->{$day};
-    }
+    $self->_day_name(\$day);
     my $days_diff = $self->{data}->{weekdays}->{$day} - $self->{datetime}->wday;
     $self->_add(day => $days_diff);
     $self->_set_modified(2);
@@ -666,14 +630,8 @@
     my $self = shift;
     my ($count, $day, $month) = @_;
     $self->_add_trace;
-    $day = ucfirst lc $day;
-    if (length $day == 3) {
-        $day = $self->{data}->{weekdays_abbrev}->{$day};
-    }
-    $month = ucfirst lc $month;
-    if (length $month == 3) {
-        $month = $self->{data}->{months_abbrev}->{$month};
-    }
+    $self->_day_name(\$day);
+    $self->_month_name(\$month);
     my $year;
     ($year, $month, $day) =
       Nth_Weekday_of_Month_Year($self->{datetime}->year,
@@ -837,6 +795,37 @@
     $self->_set_modified(2);
 }
 
+sub _day_name
+{
+    my $self = shift;
+    my ($day) = @_;
+    $$day = ucfirst lc $$day;
+    if (length $$day == 3) {
+        $$day = $self->{data}->{weekdays_abbrev}->{$$day};
+    }
+}
+
+sub _month_name
+{
+    my $self = shift;
+    my ($month) = @_;
+    $$month = ucfirst lc $$month;
+    if (length $$month == 3) {
+        $$month = $self->{data}->{months_abbrev}->{$$month};
+    }
+}
+
+sub _month_num
+{
+    my $self = shift;
+    my ($month) = @_;
+    $month = ucfirst lc $month;
+    if (length $month == 3) {
+        $month = $self->{data}->{months_abbrev}->{$month};
+    }
+    return $self->{data}->{months}->{$month};
+}
+
 sub _add
 {
     my ($self, $unit, $value) = @_;
@@ -914,7 +903,7 @@
 
 =head1 DESCRIPTION
 
-The C<DateTime::Format::Natural::Base> module defines the core functionality of
+The C<DateTime::Format::Natural::Base> class defines the core functionality of
 C<DateTime::Format::Natural>.
 
 =head1 SEE ALSO

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=24427&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 Thu Aug 21 01:04:48 2008
@@ -5,7 +5,7 @@
 
 our ($VERSION, $AUTOLOAD);
 
-$VERSION = '0.8';
+$VERSION = '0.9';
 
 sub __new
 {
@@ -57,8 +57,8 @@
 
 =head1 DESCRIPTION
 
-The C<DateTime::Format::Natural::Lang::Base> module defines the core functionality for
-C<DateTime::Format::Natural::Lang::> classes.
+The C<DateTime::Format::Natural::Lang::Base> class defines the core functionality for
+C<DateTime::Format::Natural::Lang::> grammar classes.
 
 =head1 SEE ALSO
 

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=24427&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse Thu Aug 21 01:04:48 2008
@@ -30,7 +30,8 @@
                           l|lang=s
                           p|prefer_future
                           s|supported
-                          t|trace
+                          t|time_zone=s
+                          T|trace
                           V|version)) or usage();
 
     usage()     if $opts{h};
@@ -45,12 +46,13 @@
     my $opts = shift;
 
     $lang  = $opts->{l} || LANG_DEFAULT;
-    $trace = $opts->{t} || 0;
+    $trace = $opts->{T} || 0;
 
     my %table = (
         l => 'lang',
         f => 'format',
         p => 'prefer_future',
+        t => 'time_zone',
     );
 
     foreach my $opt (keys %$opts) {
@@ -69,7 +71,8 @@
   -l, --lang             language code
   -p, --prefer_future    use futuristic dates (when possible)
   -s, --supported        list of supported languages
-  -t, --trace            print trace after processing
+  -t, --time_zone        time zone string
+  -T, --trace            print trace after processing
   -V, --version          print version
 USAGE
     exit;
@@ -99,14 +102,14 @@
 
     while (defined(my $input = $term->readline($prompt))) {
         $term->addhistory($input) if $input =~ /\S/;
-        last if $input =~ /^(?:quit|exit)$/;
+        last if $input =~ /^(?:q(?:uit)?|exit)$/;
 
         if ($input =~ /^(?:\?|help)$/i) {
             print <<EOT;
 
 Commands
  ?, help                this help screen
- exit, quit             leave dateparse
+ exit, q, quit          leave dateparse
  everything else        datetime string
 
 EOT
@@ -143,7 +146,8 @@
    -l, --lang             language code
    -p, --prefer_future    use futuristic dates (when possible)
    -s, --supported        list of supported languages
-   -t, --trace            print trace after processing
+   -t, --time_zone        time zone string
+   -T, --trace            print trace after processing
    -V, --version          print version
 
 =head1 AUTHOR




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