r67301 - in /trunk/libdatetime-format-flexible-perl: ./ debian/ lib/DateTime/Format/ lib/DateTime/Format/Flexible/ lib/DateTime/Format/Flexible/lang/ t/ t/lib/

periapt-guest at users.alioth.debian.org periapt-guest at users.alioth.debian.org
Tue Jan 11 21:59:27 UTC 2011


Author: periapt-guest
Date: Tue Jan 11 21:59:21 2011
New Revision: 67301

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

Added:
    trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang/de.pm
      - copied unchanged from r67300, branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/de.pm
    trunk/libdatetime-format-flexible-perl/t/lang-de.t
      - copied unchanged from r67300, branches/upstream/libdatetime-format-flexible-perl/current/t/lang-de.t
Modified:
    trunk/libdatetime-format-flexible-perl/Changes
    trunk/libdatetime-format-flexible-perl/MANIFEST
    trunk/libdatetime-format-flexible-perl/META.yml
    trunk/libdatetime-format-flexible-perl/debian/changelog
    trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible.pm
    trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang.pm
    trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang/en.pm
    trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang/es.pm
    trunk/libdatetime-format-flexible-perl/t/lang-es.t
    trunk/libdatetime-format-flexible-perl/t/lib/helper.pm

Modified: trunk/libdatetime-format-flexible-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/Changes?rev=67301&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/Changes (original)
+++ trunk/libdatetime-format-flexible-perl/Changes Tue Jan 11 21:59:21 2011
@@ -1,6 +1,12 @@
 Revision history for Perl module DateTime::Format::Flexible
 
-0.18 Sat Jan 01 2010
+0.19 Fri Jan 07 2011
+   - support for German (de)
+     - thanks Mark Trettin
+   - better support for DD MM
+   - support for natural dates in all languages (3 years ago)
+
+0.18 Sat Jan 01 2011
    - move a test that was hardcoded to a year to the no_year tests. (thanks cpantesters)
 
 0.17 Tue Oct 26 2010

Modified: trunk/libdatetime-format-flexible-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/MANIFEST?rev=67301&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/MANIFEST (original)
+++ trunk/libdatetime-format-flexible-perl/MANIFEST Tue Jan 11 21:59:21 2011
@@ -8,6 +8,7 @@
 example/parse_date.pl
 lib/DateTime/Format/Flexible.pm
 lib/DateTime/Format/Flexible/lang.pm
+lib/DateTime/Format/Flexible/lang/de.pm
 lib/DateTime/Format/Flexible/lang/en.pm
 lib/DateTime/Format/Flexible/lang/es.pm
 t/001_load.t
@@ -18,6 +19,7 @@
 t/data/tests.txt
 t/data/timezones.txt
 t/ddmmyyyy.t
+t/lang-de.t
 t/lang-es.t
 t/lib/helper.pm
 t/nanoseconds.t

Modified: trunk/libdatetime-format-flexible-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/META.yml?rev=67301&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/META.yml (original)
+++ trunk/libdatetime-format-flexible-perl/META.yml Tue Jan 11 21:59:21 2011
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               DateTime-Format-Flexible
-version:            0.18
+version:            0.19
 abstract:           DateTime::Format::Flexible - Flexibly parse strings and turn them into DateTime objects.
 author:
     - Tom Heady (cpan at punch.net)

Modified: trunk/libdatetime-format-flexible-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/debian/changelog?rev=67301&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/debian/changelog (original)
+++ trunk/libdatetime-format-flexible-perl/debian/changelog Tue Jan 11 21:59:21 2011
@@ -1,8 +1,9 @@
-libdatetime-format-flexible-perl (0.18-2) UNRELEASED; urgency=low
+libdatetime-format-flexible-perl (0.19-1) UNRELEASED; urgency=low
 
   * Added myself to Uploaders 
+  * New upstream release
 
- -- Nicholas Bamber <nicholas at periapt.co.uk>  Tue, 11 Jan 2011 21:58:05 +0000
+ -- Nicholas Bamber <nicholas at periapt.co.uk>  Tue, 11 Jan 2011 22:01:53 +0000
 
 libdatetime-format-flexible-perl (0.18-1) unstable; urgency=low
 

Modified: trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible.pm?rev=67301&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible.pm (original)
+++ trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible.pm Tue Jan 11 21:59:21 2011
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.18';
+our $VERSION = '0.19';
 
 use base 'DateTime::Format::Builder';
 
@@ -247,9 +247,11 @@
 
  # D month, Y | D month, YY | D month, YYYY | DD month, Y | DD month, YY
  # DD month, YYYY
+ # nDDn XMMX
  { length => [8..13],  params => $DMY,      regex => qr{\A(\d{1,2})\sX(\d{1,2})X,?\s(\d{1,4})\z} },
  { length => [13..21], params => $DMYHMS,   regex => qr{\A(\d{1,2})\sX(\d{1,2})X,?\s(\d{1,4})\s$HMS\z} },
- { length => [16..27], params => $DMYHMSAP, regex => qr{\A(\d{1,2})\sX(\d{1,2})X,?\s(\d{1,4})\s$HMS\s?$AMPM\z} , postprocess => \&_fix_ampm },
+ { length => [16..27], params => $DMYHMSAP, regex => qr{\A(\d{1,2})\sX(\d{1,2})X,?\s(\d{1,4})\s$HMS\s?$AMPM\z}, postprocess => \&_fix_ampm },
+ { length => [7..9],   params => $DM,       regex => qr{\An(\d{1,2})n\sX(\d{1,2})X\z},                          postprocess => \&_set_default_year },
 
  # Dec 03 20:53:10 2009
  { length => [16..21], params => $MDHMSY , regex => qr{\AX(\d{1,2})X\s(\d{1,2})\s$HMS\s(\d{4})\z} } ,
@@ -443,7 +445,10 @@
         lang => $extra_args{lang},
         base => __PACKAGE__->base,
     );
+
+    printf( "# before lang: %s\n", $date ) if $ENV{DFF_DEBUG};
     ( $date , $p ) = $lang->_cleanup( $date , $p );
+    printf( "# after lang: %s\n", $date ) if $ENV{DFF_DEBUG};
 
 
     $date =~ s{($DELIM)+}{$1}mxg;   # make multiple delimeters into one
@@ -471,7 +476,7 @@
         }
     }
 
-    printf( "#-->%s (%s) [%s] \n" , $date , length( $date ) , $p->{time_zone}||q{none} ) if $ENV{DFF_DEBUG};
+    printf( "#-->%s<-- (%s) [%s] \n" , $date , length( $date ) , $p->{time_zone}||q{none} ) if $ENV{DFF_DEBUG};
     return $date;
 }
 
@@ -896,7 +901,7 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2007-2010 Tom Heady.
+Copyright 2007-2011 Tom Heady.
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of either:

Modified: trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang.pm?rev=67301&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang.pm (original)
+++ trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang.pm Tue Jan 11 21:59:21 2011
@@ -27,16 +27,25 @@
                 next;
             }
         }
-#        printf( "# not skipping %s\n", $plug ) if $ENV{DFF_DEBUG};
-
+        printf( "# not skipping %s\n", $plug ) if $ENV{DFF_DEBUG};
+
+        printf( "#   before math: %s\n", $date ) if $ENV{DFF_DEBUG};;
         $date = $self->_do_math( $plug , $date );
+        printf( "#   before string_dates: %s\n", $date ) if $ENV{DFF_DEBUG};;
         $date = $self->_string_dates( $plug , $date );
+        printf( "#   before fix_alpha_month: %s\n", $date ) if $ENV{DFF_DEBUG};;
         ( $date , $p ) = $self->_fix_alpha_month( $plug , $date , $p );
+        printf( "#   before remove_day_names: %s\n", $date ) if $ENV{DFF_DEBUG};;
         $date = $self->_remove_day_names( $plug , $date );
+        printf( "#   before fix_hours: %s\n", $date ) if $ENV{DFF_DEBUG};;
         $date = $self->_fix_hours( $plug , $date );
+        printf( "#   before remove_strings: %s\n", $date ) if $ENV{DFF_DEBUG};;
         $date = $self->_remove_strings( $plug , $date );
+        printf( "#   before locate_time: %s\n", $date ) if $ENV{DFF_DEBUG};;
         $date = $self->_locate_time( $plug , $date );
+        printf( "#   before fix_internal_tz: %s\n", $date ) if $ENV{DFF_DEBUG};;
         ( $date , $p ) = $self->_fix_internal_tz( $plug , $date , $p );
+        printf( "#   finished: %s\n", $date ) if $ENV{DFF_DEBUG};;
     }
     return ( $date , $p );
 }
@@ -61,15 +70,23 @@
 {
     my ( $self , $plug , $date ) = @_;
     my %strings = $plug->math_strings;
-    if ( $date =~ m{ago}mx )
+    my $ago = $plug->ago;
+
+    if ( $date =~ m{$ago}mix )
     {
         my $base_dt = DateTime::Format::Flexible->base->clone;
         if ( my ( $amount , $unit ) = $date =~ m{(\d+)\s+([^\s]+)}mx )
         {
+
+            printf( "#    %s => %s\n", $amount, $unit ) if $ENV{DFF_DEBUG};
             if ( exists( $strings{$unit} ) )
             {
+                printf( "#    found: %s\n", $strings{$unit} ) if $ENV{DFF_DEBUG};
                 my $ret = $base_dt->subtract( $strings{$unit} => $amount );
-                $date =~ s{$amount\s+$unit\s+ago}{}mx;
+                $date =~ s{\s{0,}$amount\s+$unit\s{0,}}{}mx;
+                printf( "#    after removing amount,unit: [%s]\n", $date ) if $ENV{DFF_DEBUG};
+                $date =~ s{$ago}{}mx;
+                printf( "#    after removing ago: [%s]\n", $date ) if $ENV{DFF_DEBUG};
                 if ( $date ) # we still have more to parse...
                 {
                     $date = $ret->ymd . ' ' . $date;
@@ -205,6 +222,8 @@
     {
         if ( $date =~ m{$rs}mxi )
         {
+            printf( "#     removing string: %s\n", $rs ) if $ENV{DFF_DEBUG};
+
             $date =~ s{$rs}{ }gmix;
         }
     }
@@ -244,7 +263,7 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2010 Tom Heady.
+Copyright 2011 Tom Heady.
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of either:

Modified: trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang/en.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang/en.pm?rev=67301&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang/en.pm (original)
+++ trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang/en.pm Tue Jan 11 21:59:21 2011
@@ -31,13 +31,13 @@
 sub days
 {
     return (
-        qr{Mon(?:day)?}i    => 1,
-        qr{Tue(?:sday)?}i   => 2,
-        qr{Wed(?:nesday)?}i => 3,
-        qr{Thu(?:rsday)?}i  => 4,
-        qr{Fri(?:day)?}i    => 5,
-        qr{Sat(?:urday)?}i  => 6,
-        qr{Sun(?:day)?}i    => 7,
+        qr{\bMon(?:day)?\b}i    => 1,
+        qr{\bTue(?:sday)?\b}i   => 2,
+        qr{\bWed(?:nesday)?\b}i => 3,
+        qr{\bThu(?:rsday)?\b}i  => 4,
+        qr{\bFri(?:day)?\b}i    => 5,
+        qr{\bSat(?:urday)?\b}i  => 6,
+        qr{\bSun(?:day)?\b}i    => 7,
     );
 }
 
@@ -124,6 +124,11 @@
     );
 }
 
+sub ago
+{
+    return qr{\bago\b}; # as in 3 years ago
+}
+
 sub math_strings
 {
     return (
@@ -215,6 +220,10 @@
 
 maps string names to real dates (now => DateTime->now)
 
+=head2 ago
+
+the word used to denote a date in the past (3 years ago)
+
 =head2 math_strings
 
 useful strings when doing datetime math
@@ -234,7 +243,7 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2010 Tom Heady.
+Copyright 2011 Tom Heady.
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of either:

Modified: trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang/es.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang/es.pm?rev=67301&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang/es.pm (original)
+++ trunk/libdatetime-format-flexible-perl/lib/DateTime/Format/Flexible/lang/es.pm Tue Jan 11 21:59:21 2011
@@ -37,13 +37,13 @@
 {
     # http://www.tarver-genealogy.net/aids/spanish/sp_dates_num.html#days
     return (
-        qr{lunes}     => 1, # Monday
-        qr{martes}    => 2, # Tuesday
-        qr{miércoles} => 3, # Wednesday
-        qr{jueves}    => 4, # Thursday
-        qr{viernes}   => 5, # Friday
-        qr{sábado}    => 6, # Saturday
-        qr{domingo}   => 7, # Sunday
+        qr{\blunes\b}     => 1, # Monday
+        qr{\bmartes\b}    => 2, # Tuesday
+        qr{\bmiércoles\b} => 3, # Wednesday
+        qr{\bjueves\b}    => 4, # Thursday
+        qr{\bviernes\b}   => 5, # Friday
+        qr{\bsábado\b}    => 6, # Saturday
+        qr{\bdomingo\b}   => 7, # Sunday
     );
 }
 
@@ -122,11 +122,17 @@
     );
 }
 
+sub ago
+{
+    return qr{\bhace\b}i; # as in 3 years ago
+}
+
 sub math_strings
 {
     return (
         ano     => 'years' ,
         anos    => 'years' ,
+        'años'  => 'years' ,
         mes     => 'months' ,
         meses   => 'months' ,
         dia     => 'days' ,
@@ -208,6 +214,10 @@
 
 maps string names to real dates (ahora => DateTime->now)
 
+=head2 ago
+
+the word use to denote a date in the past (Hace 3 años => 3 years ago)
+
 =head2 math_strings
 
 useful strings when doing datetime math
@@ -226,7 +236,7 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2010 Tom Heady.
+Copyright 2011 Tom Heady.
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of either:

Modified: trunk/libdatetime-format-flexible-perl/t/lang-es.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/t/lang-es.t?rev=67301&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/t/lang-es.t (original)
+++ trunk/libdatetime-format-flexible-perl/t/lang-es.t Tue Jan 11 21:59:21 2011
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 14;
+use Test::More tests => 15;
 use DateTime;
 
 use t::lib::helper;
@@ -48,3 +48,10 @@
     my $dt = DateTime::Format::Flexible->parse_datetime( 'infinito' );
     ok ( $dt->is_infinite() , "infinito is infinite" );
 }
+
+{
+    my ( $base_dt ) = DateTime::Format::Flexible->parse_datetime( '2005-06-07T13:14:15' );
+    DateTime::Format::Flexible->base( $base_dt );
+    my $dt = DateTime::Format::Flexible->parse_datetime( 'Hace 3 años' );
+    is( $dt->datetime, '2002-06-07T13:14:15', 'Hace 3 años => 3 years ago' );
+}

Modified: trunk/libdatetime-format-flexible-perl/t/lib/helper.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-flexible-perl/t/lib/helper.pm?rev=67301&op=diff
==============================================================================
--- trunk/libdatetime-format-flexible-perl/t/lib/helper.pm (original)
+++ trunk/libdatetime-format-flexible-perl/t/lib/helper.pm Tue Jan 11 21:59:21 2011
@@ -11,6 +11,11 @@
 
 sub run_tests
 {
+    my $opts = [];
+    if ( ref( $_[0] ) eq 'ARRAY' )
+    {
+        $opts = shift @_;
+    }
     foreach ( @_ )
     {
         my ( $line ) = $_ =~ m{([^\n]+)};
@@ -18,14 +23,14 @@
         next if $line =~ m{\A\#}mx; # skip comments
         next if $line =~ m{\A\z}mx; # skip blank lines
         my ( $given , $wanted , $tz ) = split m{\s+=>\s+}mx , $line;
-        compare( $given , $wanted , $tz );
+        compare( $given , $wanted , $tz, $opts );
     }
 }
 
 sub compare
 {
-    my ( $given , $wanted , $tz ) = @_;
-    my $dt = $base->parse_datetime( $given );
+    my ( $given , $wanted , $tz, $opts ) = @_;
+    my $dt = $base->parse_datetime( $given, @$opts );
     is( $dt->datetime , $wanted , "$given => $wanted" );
     if ( $tz )
     {




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