r67299 - in /branches/upstream/libdatetime-format-flexible-perl/current: ./ 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:58:43 UTC 2011
Author: periapt-guest
Date: Tue Jan 11 21:58:37 2011
New Revision: 67299
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=67299
Log:
[svn-upgrade] new version libdatetime-format-flexible-perl (0.19)
Added:
branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/de.pm
branches/upstream/libdatetime-format-flexible-perl/current/t/lang-de.t
Modified:
branches/upstream/libdatetime-format-flexible-perl/current/Changes
branches/upstream/libdatetime-format-flexible-perl/current/MANIFEST
branches/upstream/libdatetime-format-flexible-perl/current/META.yml
branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible.pm
branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang.pm
branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/en.pm
branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/es.pm
branches/upstream/libdatetime-format-flexible-perl/current/t/lang-es.t
branches/upstream/libdatetime-format-flexible-perl/current/t/lib/helper.pm
Modified: branches/upstream/libdatetime-format-flexible-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-flexible-perl/current/Changes?rev=67299&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-flexible-perl/current/Changes (original)
+++ branches/upstream/libdatetime-format-flexible-perl/current/Changes Tue Jan 11 21:58:37 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: branches/upstream/libdatetime-format-flexible-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-flexible-perl/current/MANIFEST?rev=67299&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-flexible-perl/current/MANIFEST (original)
+++ branches/upstream/libdatetime-format-flexible-perl/current/MANIFEST Tue Jan 11 21:58:37 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: branches/upstream/libdatetime-format-flexible-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-flexible-perl/current/META.yml?rev=67299&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-flexible-perl/current/META.yml (original)
+++ branches/upstream/libdatetime-format-flexible-perl/current/META.yml Tue Jan 11 21:58:37 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: branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible.pm?rev=67299&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible.pm (original)
+++ branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible.pm Tue Jan 11 21:58:37 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: branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang.pm?rev=67299&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang.pm (original)
+++ branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang.pm Tue Jan 11 21:58:37 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:
Added: branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/de.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/de.pm?rev=67299&op=file
==============================================================================
--- branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/de.pm (added)
+++ branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/de.pm Tue Jan 11 21:58:37 2011
@@ -1,0 +1,266 @@
+package DateTime::Format::Flexible::lang::de;
+
+use strict;
+use warnings;
+
+sub new
+{
+ my ( $class , %params ) = @_;
+ my $self = bless \%params , $class;
+ return $self;
+}
+
+sub months
+{
+ return (
+ qr{Jan(?:uar)?}i => 1,
+ qr{Jän(?:er)?}i => 1, # Austrian?!
+ qr{Feb(?:ruar)?}i => 2,
+ qr{Mär(?:z)?|Maerz}i => 3,
+ qr{Apr(?:il)?}i => 4,
+ qr{Mai}i => 5,
+ qr{Jun(?:i)?}i => 6,
+ qr{Jul(?:i)?}i => 7,
+ qr{Aug(?:ust)?}i => 8,
+ qr{Sep(?:tember)?}i => 9,
+ qr{Okt(?:ober)?}i => 10,
+ qr{Nov(?:ember)?}i => 11,
+ qr{Dez(?:ember)?}i => 12,
+ );
+}
+
+sub days
+{
+ return (
+ qr{\bMo(?:ntag)?\b}i => 1, # Monday
+ qr{\bDi(?:enstag)?\b}i => 2, # Tuesday
+ qr{\bMi(?:ttwoch)?\b}i => 3, # Wednesday
+ qr{\bDo(?:nnerstag)?\b}i => 4, # Thursday
+ qr{\bFr(?:eitag)?\b}i => 5, # Friday
+ qr{\bSa(?:mmstag)?\b}i => 6, # Saturday
+ qr{\bSonnabend\b}i => 6, # Saturday
+ qr{\bSo(?:nntag)?\b}i => 7, # Sunday
+ );
+}
+
+sub day_numbers
+{
+ return (
+ qr{erster}i => 1, # first
+ qr{ersten}i => 1, # first
+ qr{zweiter}i => 2, # second
+ qr{dritter}i => 3, # third
+ qr{vierter}i => 4, # fourth
+ qr{fünfter|fuenfter}i => 5, # fifth
+ qr{sechster}i => 6, # sixth
+ qr{siebter}i => 7, # seventh
+ qr{achter}i => 8, # eighth
+ qr{neunter}i => 9, # ninth
+ qr{zehnter}i => 10, # tenth
+ qr{elfter}i => 11, # eleventh
+ qr{zwölfter|zwoelfter}i => 12, # twelfth
+ qr{dreizehnter}i => 13, # thirteenth
+ qr{vierzehnter}i => 14, # fourteenth
+ qr{vierzehnten}i => 14, # fourteenth
+ qr{fünfzehnter|fuenfzehnter}i => 15, # fifteenth
+ qr{sechzehnter}i => 16, # sixteenth
+ qr{siebzehnter}i => 17, # seventeenth
+ qr{achtzehnter}i => 18, # eithteenth
+ qr{neunzehnter}i => 19, # ninteenth
+ qr{zwanzigster}i => 20, # twentieth
+ qr{einundzwanzigster}i => 21, # twenty first
+ qr{zweiundzwanzigster}i => 22, # twenty second
+ qr{dreiundzwanzigster}i => 23, # twenty third
+ qr{vierundzwanzigster}i => 24, # twenty fourth
+ qr{fünfundzwanzigster|fuenfundzwanzigster}i => 25, # twenty fifth
+ qr{sechsundzwanzigster}i => 26, # twenty sixth
+ qr{siebenundzwanzigster}i => 27, # twenty seventh
+ qr{achtundzwanzigster}i => 28, # twenty eighth
+ qr{neunundzwanzigster}i => 29, # twenty ninth
+ qr{dreißigster|dreissigster}i => 30, # thirtieth
+ qr{einunddreißigster|einunddreissigster}i => 31, # thirty first
+ );
+}
+
+sub hours
+{
+ return (
+ Mittag => '12:00:00', # noon
+ mittags => '12:00:00', # noon
+ Mitternacht => '00:00:00', # midnight
+ mitternachts => '00:00:00', # midnight
+ );
+}
+
+sub remove_strings
+{
+ return (
+ # we want to remove ' am ' only when it does not follow a digit
+ # if we just remove ' am ', it removes am/pm designation, losing accuracy
+ qr{(?<!\d)\sam\b}i, # remove ' am ' as in '20. Feb am Mittag'
+ # we can also remove it if it is at the beginning
+ qr{\A\bam\b}i,
+ qr{\bum\b}i, # remove ' um ' as in '20. Feb um Mitternacht'
+ );
+}
+
+sub parse_time
+{
+ my ( $self, $date ) = @_;
+ return $date;
+}
+
+sub string_dates
+{
+ my $base_dt = DateTime::Format::Flexible->base;
+ return (
+ jetzt => sub { return $base_dt->datetime }, # now
+ heute => sub { return $base_dt->clone->truncate( to => 'day' )->ymd } , # today
+ morgen => sub { return $base_dt->clone->truncate( to => 'day' )->add( days => 1 )->ymd }, # tomorrow
+ gestern => sub { return $base_dt->clone->truncate( to => 'day' )->subtract( days => 1 )->ymd }, # yesterday
+ 'übermorgen' => sub { return DateTime->today->add( days => 2 )->ymd }, # overmorrow (the day after tomorrow) don't know if the Umlaut works
+ uebermorgen => sub { return DateTime->today->add( days => 2 )->ymd }, # overmorrow (the day after tomorrow)
+ Epoche => sub { return DateTime->from_epoch( epoch => 0 ) },
+ '-unendlich' => sub { return '-infinity' },
+ unendlich => sub { return 'infinity' },
+ );
+}
+
+sub ago
+{
+ return qr{\bvor\b}; # as in 3 years ago
+}
+
+sub math_strings
+{
+ return (
+ Jahr => 'years' ,
+ Jahre => 'years' ,
+ Jahren => 'years' ,
+ Monat => 'months' ,
+ Monate => 'months' ,
+ Tag => 'days' ,
+ Tage => 'days' ,
+ Stunde => 'hours' ,
+ Stunden => 'hours' ,
+ Minute => 'minutes' ,
+ Minuten => 'minutes' ,
+ );
+}
+
+sub timezone_map
+{
+ # http://home.tiscali.nl/~t876506/TZworld.html
+ return (
+ CET => 'Europe/Berlin',
+ CEST => 'Europe/Berlin',
+ MEZ => 'Europe/Berlin', # German Version: Mitteleuropäische Zeit
+ MESZ => 'Europe/Berlin', # Mitteleuropäische Sommerzeit
+ );
+}
+
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+DateTime::Format::Flexible::lang::de - german language plugin
+
+=head1 DESCRIPTION
+
+You should not need to use this module directly.
+
+If you only want to use one language, specify the lang property when parsing a date.
+
+example:
+
+ my $dt = DateTime::Format::Flexible->parse_datetime(
+ 'Montag, 6. Dez 2010' ,
+ lang => ['de']
+ );
+ # $dt is now 2010-12-06T00:00:00
+
+Note that this is not required, by default ALL languages are scanned when trying to parse a date.
+
+=head2 new
+
+Instantiate a new instance of this module.
+
+=head2 months
+
+month name regular expressions along with the month numbers (Jan(:?uar)? => 1)
+
+=head2 days
+
+day name regular expressions along the the day numbers (Montag => 1)
+
+=head2 day_numbers
+
+maps day of month names to the corresponding numbers (erster => 01)
+
+=head2 hours
+
+maps hour names to numbers (Mittag => 12:00:00)
+
+=head2 remove_strings
+
+strings to remove from the date (um as in um Mitternacht)
+
+=head2 parse_time
+
+currently does nothing
+
+=head2 string_dates
+
+maps string names to real dates (jetzt => DateTime->now)
+
+=head2 ago
+
+the word use to denote a date in the past (vor 3 Jahren => 3 years ago)
+
+=head2 math_strings
+
+useful strings when doing datetime math
+
+=head2 timezone_map
+
+maps unofficial timezones to official timezones for this language (MEZ => Europe/Berlin)
+
+=head1 AUTHOR
+
+ Mark Trettin <nulldevice.mark at gmx.de>
+
+ Based on DateTime::Format::Flexible::lang::en by
+ Tom Heady
+ CPAN ID: thinc
+ Punch, Inc.
+ cpan at punch.net
+ http://www.punch.net/
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2011 Mark Trettin.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of either:
+
+=over 4
+
+=item * the GNU General Public License as published by the Free
+ Software Foundation; either version 1, or (at your option) any
+ later version, or
+
+=item * the Artistic License version 2.0.
+
+=back
+
+=head1 SEE ALSO
+
+F<DateTime::Format::Flexible>
+
+=cut
+### Local variables:
+### coding: utf-8
+### End:
Modified: branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/en.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/en.pm?rev=67299&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/en.pm (original)
+++ branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/en.pm Tue Jan 11 21:58:37 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: branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/es.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/es.pm?rev=67299&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/es.pm (original)
+++ branches/upstream/libdatetime-format-flexible-perl/current/lib/DateTime/Format/Flexible/lang/es.pm Tue Jan 11 21:58:37 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:
Added: branches/upstream/libdatetime-format-flexible-perl/current/t/lang-de.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-flexible-perl/current/t/lang-de.t?rev=67299&op=file
==============================================================================
--- branches/upstream/libdatetime-format-flexible-perl/current/t/lang-de.t (added)
+++ branches/upstream/libdatetime-format-flexible-perl/current/t/lang-de.t Tue Jan 11 21:58:37 2011
@@ -1,0 +1,62 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 18;
+use DateTime;
+
+use t::lib::helper;
+
+use DateTime::Format::Flexible;
+
+my $curr_year = DateTime->now->year;
+
+# http://www.dummies.com/how-to/content/mastering-the-calendar-and-dates-in-german.html
+# http://german.about.com/library/anfang/blanfang12b.htm
+t::lib::helper::run_tests(
+ [ european => 1 ],
+ "20. Feb am Mittag => $curr_year-02-20T12:00:00",
+ "20. Feb um Mitternacht => $curr_year-02-20T00:00:00",
+ 'Montag, 6. Dez 2010 => 2010-12-06T00:00:00',
+ "am vierzehnten Juni => $curr_year-06-14T00:00:00",
+ 'am 14. Juni 2001 => 2001-06-14T00:00:00',
+ '1. Januar 2000 => 2000-01-01T00:00:00',
+ '10. Juni 1999 => 1999-06-10T00:00:00',
+ '20. März 1888 => 1888-03-20T00:00:00',
+ "am ersten Mai => $curr_year-05-01T00:00:00",
+ 'am 1. Mai 2001 => 2001-05-01T00:00:00',
+ '14.7.01 => 2001-07-14T00:00:00',
+ '1.5.01 => 2001-05-01T00:00:00',
+);
+
+{
+ my $dt = DateTime::Format::Flexible->parse_datetime( '1. 1. 2000', european => 1 );
+ is ( $dt->datetime, '2000-01-01T00:00:00', '1. 1. 2000 => 2000-01-01T00:00:00' );
+}
+{
+ my $dt = DateTime::Format::Flexible->parse_datetime( '2. 4. 1999', european => 1 );
+ is ( $dt->datetime, '1999-04-02T00:00:00', '2. 4. 1999 => 1999-04-02T00:00:00' );
+}
+{
+ my $dt = DateTime::Format::Flexible->parse_datetime( '3. 5. 1617', european => 1 );
+ is ( $dt->datetime, '1617-05-03T00:00:00', '3. 5. 1617 => 1617-05-03T00:00:00' );
+}
+
+{
+ my $dt = DateTime::Format::Flexible->parse_datetime( '-unendlich' );
+ ok ( $dt->is_infinite() , '-unendlich is infinite' );
+}
+
+{
+ my $dt = DateTime::Format::Flexible->parse_datetime( 'unendlich' );
+ ok ( $dt->is_infinite() , 'unendlich 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( 'vor 3 Jahren' );
+ is( $dt->datetime, '2002-06-07T13:14:15', 'vor 3 Jahren => 3 years ago' );
+
+}
Modified: branches/upstream/libdatetime-format-flexible-perl/current/t/lang-es.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-flexible-perl/current/t/lang-es.t?rev=67299&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-flexible-perl/current/t/lang-es.t (original)
+++ branches/upstream/libdatetime-format-flexible-perl/current/t/lang-es.t Tue Jan 11 21:58:37 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: branches/upstream/libdatetime-format-flexible-perl/current/t/lib/helper.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-flexible-perl/current/t/lib/helper.pm?rev=67299&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-flexible-perl/current/t/lib/helper.pm (original)
+++ branches/upstream/libdatetime-format-flexible-perl/current/t/lib/helper.pm Tue Jan 11 21:58:37 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