r24868 - in /branches/upstream/libdatetime-format-natural-perl/current: ./ lib/DateTime/Format/ lib/DateTime/Format/Natural/ lib/DateTime/Format/Natural/Lang/ scripts/ t/
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Sat Sep 6 18:13:56 UTC 2008
Author: gregoa
Date: Sat Sep 6 18:13:53 2008
New Revision: 24868
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=24868
Log:
[svn-upgrade] Integrating new upstream version, libdatetime-format-natural-perl (0.73)
Modified:
branches/upstream/libdatetime-format-natural-perl/current/Build.PL
branches/upstream/libdatetime-format-natural-perl/current/Changes
branches/upstream/libdatetime-format-natural-perl/current/META.yml
branches/upstream/libdatetime-format-natural-perl/current/Makefile.PL
branches/upstream/libdatetime-format-natural-perl/current/README
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/EN.pm
branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse
branches/upstream/libdatetime-format-natural-perl/current/t/06-parse_prefer_future.t
Modified: branches/upstream/libdatetime-format-natural-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/Build.PL?rev=24868&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/Build.PL (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/Build.PL Sat Sep 6 18:13:53 2008
@@ -11,6 +11,7 @@
dist_author => 'Steven Schubiger <schubiger at cpan.org>',
dist_version_from => 'lib/DateTime/Format/Natural.pm',
requires => {
+ 'boolean' => 0,
'Date::Calc' => 0,
'DateTime' => 0,
'List::MoreUtils' => 0,
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=24868&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/Changes (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/Changes Sat Sep 6 18:13:53 2008
@@ -1,4 +1,28 @@
Revision history for Perl extension DateTime::Format::Natural.
+
+0.73 Thu Sep 4 19:53:44 CEST 2008
+
+ - Fixed the 'prefer_future' parameter validation error by
+ extending its type definition.
+
+ - Merged development version to stable.
+
+0.72_02 Thu Sep 4 11:06:36 CEST 2008
+
+ - Use the "boolean" pragma for true/false values.
+
+0.72_01 Sun Aug 31 12:33:53 CEST 2008
+
+ - Adjusted the dispatch entries for exact non-formatted dates
+ and introduced an according method to avoid false errors.
+ [rt #38857 - Ankur Gupta <ankur655 at gmail.com>]
+
+ - Call DateTime's set method for exact formatted dates once
+ instead of setting each unit separately.
+
+ - Changed the parser to handle internal value positions (i.e.,
+ data related to tokens) with more respect when encountering
+ lists with a sequence that differs from a truly ascending one.
0.72 Sat Aug 16 13:39:27 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=24868&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/META.yml (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/META.yml Sat Sep 6 18:13:53 2008
@@ -1,6 +1,6 @@
---
name: DateTime-Format-Natural
-version: 0.72
+version: 0.73
author:
- 'Steven Schubiger <schubiger at cpan.org>'
abstract: Create machine readable date/time with natural parsing logic
@@ -13,6 +13,7 @@
List::MoreUtils: 0
Params::Validate: 0
Term::ReadLine: 0
+ boolean: 0
build_requires:
Test::MockTime: 0
Test::More: 0
@@ -22,16 +23,16 @@
provides:
DateTime::Format::Natural:
file: lib/DateTime/Format/Natural.pm
- version: 0.72
+ version: 0.73
DateTime::Format::Natural::Base:
file: lib/DateTime/Format/Natural/Base.pm
- version: 1.13
+ version: 1.15
DateTime::Format::Natural::Lang::Base:
file: lib/DateTime/Format/Natural/Lang/Base.pm
version: 0.9
DateTime::Format::Natural::Lang::EN:
file: lib/DateTime/Format/Natural/Lang/EN.pm
- version: 1.11
+ version: 1.12
generated_by: Module::Build version 0.2808
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
Modified: branches/upstream/libdatetime-format-natural-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/Makefile.PL?rev=24868&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/Makefile.PL (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/Makefile.PL Sat Sep 6 18:13:53 2008
@@ -10,12 +10,13 @@
],
'VERSION_FROM' => 'lib/DateTime/Format/Natural.pm',
'PREREQ_PM' => {
+ 'DateTime' => 0,
+ 'Test::MockTime' => 0,
+ 'Date::Calc' => 0,
'Test::More' => 0,
- 'DateTime' => 0,
- 'Date::Calc' => 0,
+ 'boolean' => 0,
+ 'Params::Validate' => 0,
'Term::ReadLine' => 0,
- 'Params::Validate' => 0,
- 'Test::MockTime' => 0,
'List::MoreUtils' => 0
}
)
Modified: branches/upstream/libdatetime-format-natural-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/README?rev=24868&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/README (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/README Sat Sep 6 18:13:53 2008
@@ -52,7 +52,7 @@
* "prefer_future"
Turns ambigious weekdays/months to their futuristic relatives.
- Accepts a boolean, defaults to 0.
+ Accepts a boolean, defaults to false.
* "time_zone"
The time zone to use when parsing and for output. Accepts any time
@@ -128,6 +128,7 @@
Jesse Vincent
Jason May
Pat Kale
+ Ankur Gupta
SEE ALSO
DateTime, Date::Calc, <http://datetime.perl.org>
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=24868&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 Sat Sep 6 18:13:53 2008
@@ -3,6 +3,7 @@
use strict;
use warnings;
use base qw(DateTime::Format::Natural::Base);
+use boolean qw(true false);
use Carp qw(croak);
use DateTime ();
@@ -10,7 +11,7 @@
use List::MoreUtils qw(all any);
use Params::Validate ':all';
-our $VERSION = '0.72';
+our $VERSION = '0.73';
validation_options(
on_fail => sub
@@ -40,7 +41,7 @@
$self->{Format} = $opts{format} || 'd/m/y';
$self->{Lang} = $opts{lang} || 'en';
- $self->{Prefer_future} = $opts{prefer_future} || 0;
+ $self->{Prefer_future} = $opts{prefer_future} || false;
$self->{Time_zone} = $opts{time_zone} || 'floating';
$self->{Opts}{daytime} = $opts{daytime};
@@ -58,22 +59,22 @@
validate(@_, {
lang => {
type => SCALAR,
- optional => 1,
+ optional => true,
regex => qr!^(?:en)$!,
},
format => {
type => SCALAR,
- optional => 1,
+ optional => true,
regex => qr!^(?:[dmy]{1,4}[-./]){2}[dmy]{1,4}$!i,
},
prefer_future => {
- type => SCALAR,
- optional => 1,
- regex => qr!^[01]$!,
+ # SCALARREF due to boolean.pm's implementation
+ type => BOOLEAN | SCALARREF,
+ optional => true,
},
time_zone => {
type => SCALAR,
- optional => 1,
+ optional => true,
callbacks => {
'valid timezone' => sub
{
@@ -84,7 +85,7 @@
},
daytime => {
type => HASHREF,
- optional => 1,
+ optional => true,
},
});
}
@@ -164,9 +165,11 @@
return $self->_get_datetime_object;
}
- $self->{datetime}->set_year($year);
- $self->{datetime}->set_month($month);
- $self->{datetime}->set_day($day);
+ $self->{datetime}->set(
+ year => $year,
+ month => $month,
+ day => $day,
+ );
$self->_set_valid_exp;
$self->_set_modified(1);
@@ -240,7 +243,7 @@
{
my $self = shift;
- return ($self->_get_valid_exp && !$self->_get_failure) ? 1 : 0;
+ return ($self->_get_valid_exp && !$self->_get_failure) ? true : false;
}
sub error
@@ -279,7 +282,7 @@
last if $self->_get_modified >= @{$self->{tokens}};
foreach my $expression (@grammar) {
- my $valid_expression = 1;
+ my $valid_expression = true;
my $definition = $expression->[0];
my @positions = keys %$definition;
my %regex_stack;
@@ -290,7 +293,7 @@
next;
}
else {
- $valid_expression = 0;
+ $valid_expression = false;
}
}
}
@@ -301,7 +304,7 @@
next;
}
else {
- $valid_expression = 0;
+ $valid_expression = false;
}
}
else {
@@ -313,9 +316,9 @@
$self->_set_valid_exp;
my $i;
foreach my $positions (@{$expression->[1]}) {
- my @values;
+ my ($c, @values);
foreach my $pos (@$positions) {
- $values[$pos] = exists $regex_stack{$pos}
+ $values[$c++] = exists $regex_stack{$pos}
? $regex_stack{$pos}
: ${$self->_token($pos)};
}
@@ -336,7 +339,7 @@
my $self = shift;
if ($self->{Prefer_future}) {
- my %modified = map { $_ => 1 } grep { $_ ne 'total' } keys %{$self->{modified}};
+ my %modified = map { $_ => true } grep { $_ ne 'total' } keys %{$self->{modified}};
if ($self->{count}{tokens} == 1
&& (any { $self->{tokens}->[0] =~ /$_/i } @{$self->{data}->{weekdays_all}})
@@ -352,8 +355,8 @@
&& (exists $self->{modified}{month} && $self->{modified}{month} == 1)
&& (exists $self->{modified}{day}
? $self->{modified}{day} == 1
- ? 1 : 0
- : 1)
+ ? true : false
+ : true)
&& ($self->{datetime}->day_of_year < DateTime->now->day_of_year)
) {
$self->{postprocess}{year} = 1;
@@ -380,13 +383,13 @@
sub _set_error { $_[0]->{error} = $_[1] }
sub _unset_error { $_[0]->{error} = '' }
-sub _get_failure { $_[0]->{failure} }
-sub _set_failure { $_[0]->{failure} = 1 }
-sub _unset_failure { $_[0]->{failure} = 0 }
-
-sub _get_valid_exp { $_[0]->{valid_expression} }
-sub _set_valid_exp { $_[0]->{valid_expression} = 1 }
-sub _unset_valid_exp { $_[0]->{valid_expression} = 0 }
+sub _get_failure { $_[0]->{failure} }
+sub _set_failure { $_[0]->{failure} = true }
+sub _unset_failure { $_[0]->{failure} = false }
+
+sub _get_valid_exp { $_[0]->{valid_expression} }
+sub _set_valid_exp { $_[0]->{valid_expression} = true }
+sub _unset_valid_exp { $_[0]->{valid_expression} = false }
sub _get_modified { $_[0]->{modified}{total} || 0 }
sub _set_modified { $_[0]->{modified}{total} += $_[1] }
@@ -437,7 +440,7 @@
hour => $hour,
minute => $min,
second => $sec);
- $self->{running_tests} = 1;
+ $self->{running_tests} = true;
}
1;
@@ -505,7 +508,7 @@
=item * C<prefer_future>
Turns ambigious weekdays/months to their futuristic relatives. Accepts a boolean,
-defaults to 0.
+defaults to false.
=item * C<time_zone>
@@ -597,6 +600,7 @@
Jesse Vincent
Jason May
Pat Kale
+ Ankur Gupta
=head1 SEE ALSO
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=24868&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 Sat Sep 6 18:13:53 2008
@@ -2,13 +2,14 @@
use strict;
use warnings;
+use boolean qw(true false);
use Date::Calc qw(Add_Delta_Days
Decode_Day_of_Week
Nth_Weekday_of_Month_Year
check_date check_time);
-our $VERSION = '1.13';
+our $VERSION = '1.15';
use constant MORNING => '08';
use constant AFTERNOON => '14';
@@ -795,6 +796,20 @@
$self->_set_modified(2);
}
+sub _day_month_year
+{
+ my $self = shift;
+ $self->_add_trace;
+ my ($day, $month, $year) = @_;
+ $self->_month_name(\$month);
+ $self->{datetime}->set(
+ year => $year,
+ month => $self->_month_num($month),
+ day => $day,
+ );
+ $self->_set_modified(3);
+}
+
sub _day_name
{
my $self = shift;
@@ -864,12 +879,12 @@
$set{$type} = $value;
if (check_date($set{year}, $set{month}, $set{day})) {
- return 1;
+ return true;
}
else {
$self->_set_failure;
$self->_set_error("('$value' is not a valid $type)");
- return 0;
+ return false;
}
}
@@ -881,12 +896,12 @@
$set{$type} = $value;
if (check_time($set{hour}, $set{min}, $set{sec})) {
- return 1;
+ return true;
}
else {
$self->_set_failure;
$self->_set_error("('$value' is not a valid $type)");
- return 0;
+ return false;
}
}
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=24868&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 Sat Sep 6 18:13:53 2008
@@ -4,7 +4,7 @@
use warnings;
use base qw(DateTime::Format::Natural::Lang::Base);
-our $VERSION = '1.11';
+our $VERSION = '1.12';
our (%init,
%timespan,
@@ -890,13 +890,13 @@
[ 'REGEXP', 'REGEXP', 'REGEXP' ],
[
{ 0 => $RE{monthday}, 1 => $RE{month}, 2 => $RE{year} },
- [ [ 0 ], [ 1 ], [ 2 ] ],
- [ '_day', '_month', '_year' ],
+ [ [ 0, 1, 2 ] ],
+ [ '_day_month_year' ],
],
[
{ 0 => $RE{month}, 1 => $RE{monthday}, 2 => $RE{year} },
- [ [ 0 ], [ 1 ], [ 2 ] ],
- [ '_month', '_day', '_year' ],
+ [ [ 1, 0, 2 ] ],
+ [ '_day_month_year' ],
],
],
count_weekday_in_month => [
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=24868&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/scripts/dateparse Sat Sep 6 18:13:53 2008
@@ -2,6 +2,7 @@
use strict;
use warnings;
+use boolean qw(true false);
use DateTime::Format::Natural;
use Getopt::Long qw(:config no_auto_abbrev no_ignore_case);
@@ -13,7 +14,7 @@
my $lang;
my @supported_languages = qw(en);
my $trace;
-my %valid_languages = map { $_ => 1 } @supported_languages;
+my %valid_languages = map { $_ => true } @supported_languages;
{
my $opts = {};
@@ -46,7 +47,7 @@
my $opts = shift;
$lang = $opts->{l} || LANG_DEFAULT;
- $trace = $opts->{T} || 0;
+ $trace = $opts->{T} || false;
my %table = (
l => 'lang',
Modified: branches/upstream/libdatetime-format-natural-perl/current/t/06-parse_prefer_future.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-natural-perl/current/t/06-parse_prefer_future.t?rev=24868&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-natural-perl/current/t/06-parse_prefer_future.t (original)
+++ branches/upstream/libdatetime-format-natural-perl/current/t/06-parse_prefer_future.t Sat Sep 6 18:13:53 2008
@@ -2,6 +2,7 @@
use strict;
use warnings;
+use boolean qw(true);
use Test::MockTime qw(set_fixed_time);
use DateTime::Format::Natural;
@@ -33,7 +34,7 @@
{
my ($string, $result) = @_;
- my $parse = DateTime::Format::Natural->new(lang => 'en', prefer_future => 1);
+ my $parse = DateTime::Format::Natural->new(lang => 'en', prefer_future => true);
my $dt = $parse->parse_datetime(string => $string);
my $res_string = sprintf("%02d.%02d.%4d %02d:%02d:%02d", $dt->day, $dt->month, $dt->year, $dt->hour, $dt->min, $dt->sec);
More information about the Pkg-perl-cvs-commits
mailing list