r44365 - in /trunk/libdatetime-format-natural-perl: ./ debian/ 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:09:55 UTC 2009
Author: carnil-guest
Date: Sat Sep 19 23:09:50 2009
New Revision: 44365
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=44365
Log:
* New upstream release
* Bump Standards-Version to 3.8.3 (no changes)
Added:
trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Duration.pm
- copied unchanged from r44364, branches/upstream/libdatetime-format-natural-perl/current/lib/DateTime/Format/Natural/Duration.pm
trunk/libdatetime-format-natural-perl/t/10-state.t
- copied unchanged from r44364, branches/upstream/libdatetime-format-natural-perl/current/t/10-state.t
Modified:
trunk/libdatetime-format-natural-perl/Changes
trunk/libdatetime-format-natural-perl/MANIFEST
trunk/libdatetime-format-natural-perl/META.yml
trunk/libdatetime-format-natural-perl/debian/changelog
trunk/libdatetime-format-natural-perl/debian/control
trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm
trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Base.pm
trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Compat.pm
trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/Base.pm
trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm
trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Test.pm
trunk/libdatetime-format-natural-perl/scripts/dateparse
trunk/libdatetime-format-natural-perl/t/00-load.t
trunk/libdatetime-format-natural-perl/t/01-parse.t
trunk/libdatetime-format-natural-perl/t/02-parse_format.t
trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t
trunk/libdatetime-format-natural-perl/t/04-parse_durations.t
trunk/libdatetime-format-natural-perl/t/05-parse_time_zone.t
trunk/libdatetime-format-natural-perl/t/06-parse_prefer_future.t
trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t
trunk/libdatetime-format-natural-perl/t/09-regression.t
Modified: trunk/libdatetime-format-natural-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/Changes?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/Changes (original)
+++ trunk/libdatetime-format-natural-perl/Changes Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/MANIFEST?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/MANIFEST (original)
+++ trunk/libdatetime-format-natural-perl/MANIFEST Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/META.yml?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/META.yml (original)
+++ trunk/libdatetime-format-natural-perl/META.yml Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/debian/changelog?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/debian/changelog (original)
+++ trunk/libdatetime-format-natural-perl/debian/changelog Sat Sep 19 23:09:50 2009
@@ -1,10 +1,12 @@
-libdatetime-format-natural-perl (0.78-2) UNRELEASED; urgency=low
+libdatetime-format-natural-perl (0.79-1) UNRELEASED; urgency=low
+ * New upstream release
* debian/control: Changed: Replace versioned (build-)dependency on
perl (>= 5.6.0-{12,16}) with an unversioned dependency on perl (as
permitted by Debian Policy 3.8.3).
+ * Bump Standards-Version to 3.8.3 (no changes)
- -- Salvatore Bonaccorso <salvatore.bonaccorso at gmail.com> Sun, 16 Aug 2009 20:13:53 +0200
+ -- Salvatore Bonaccorso <salvatore.bonaccorso at gmail.com> Sat, 19 Sep 2009 23:07:38 +0000
libdatetime-format-natural-perl (0.78-1) unstable; urgency=low
Modified: trunk/libdatetime-format-natural-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/debian/control?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/debian/control (original)
+++ trunk/libdatetime-format-natural-perl/debian/control Sat Sep 19 23:09:50 2009
@@ -10,7 +10,7 @@
gregor herrmann <gregoa at debian.org>, Rene Mayorga <rmayorga at debian.org>,
Angel Abad (Ikusnet SLL) <angel at grupoikusnet.com>,
Salvatore Bonaccorso <salvatore.bonaccorso at gmail.com>
-Standards-Version: 3.8.2
+Standards-Version: 3.8.3
Homepage: http://search.cpan.org/dist/DateTime-Format-Natural/
Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libdatetime-format-natural-perl/
Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libdatetime-format-natural-perl/
Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural.pm Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Base.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Base.pm?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Base.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Base.pm Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Compat.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Compat.pm?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Compat.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Compat.pm Sat Sep 19 23:09:50 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 !$@;
}
Modified: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/Base.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/Base.pm?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/Base.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/Base.pm Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Lang/EN.pm Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Test.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Test.pm?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Test.pm (original)
+++ trunk/libdatetime-format-natural-perl/lib/DateTime/Format/Natural/Test.pm Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/scripts/dateparse
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/scripts/dateparse?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/scripts/dateparse (original)
+++ trunk/libdatetime-format-natural-perl/scripts/dateparse Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/00-load.t?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/00-load.t (original)
+++ trunk/libdatetime-format-natural-perl/t/00-load.t Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/t/01-parse.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/01-parse.t?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/01-parse.t (original)
+++ trunk/libdatetime-format-natural-perl/t/01-parse.t Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/t/02-parse_format.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/02-parse_format.t?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/02-parse_format.t (original)
+++ trunk/libdatetime-format-natural-perl/t/02-parse_format.t Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t (original)
+++ trunk/libdatetime-format-natural-perl/t/03-parse_daytime.t Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/t/04-parse_durations.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/04-parse_durations.t?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/04-parse_durations.t (original)
+++ trunk/libdatetime-format-natural-perl/t/04-parse_durations.t Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/t/05-parse_time_zone.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/05-parse_time_zone.t?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/05-parse_time_zone.t (original)
+++ trunk/libdatetime-format-natural-perl/t/05-parse_time_zone.t Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/t/06-parse_prefer_future.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/06-parse_prefer_future.t?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/06-parse_prefer_future.t (original)
+++ trunk/libdatetime-format-natural-perl/t/06-parse_prefer_future.t Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t (original)
+++ trunk/libdatetime-format-natural-perl/t/07-parse_datetime.t Sat Sep 19 23:09:50 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: trunk/libdatetime-format-natural-perl/t/09-regression.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdatetime-format-natural-perl/t/09-regression.t?rev=44365&op=diff
==============================================================================
--- trunk/libdatetime-format-natural-perl/t/09-regression.t (original)
+++ trunk/libdatetime-format-natural-perl/t/09-regression.t Sat Sep 19 23:09:50 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');
}
More information about the Pkg-perl-cvs-commits
mailing list