Skip to content

Commit

Permalink
RT#17396: Parse error for french date with 'mars' (march) as month
Browse files Browse the repository at this point in the history
need to anchor with \b when removing day names to ignore
  • Loading branch information
gbarr committed Sep 19, 2009
1 parent 426af5f commit 6159051
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Date/Parse.pm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ sub {
# ignore day names
$dtstr =~ s#([\d\w\s])[\.\,]\s#$1 #sog;
$dtstr =~ s/,/ /g;
$dtstr =~ s#($daypat)\s*(den\s)?# #o;
$dtstr =~ s#($daypat)\s*(den\s)?\b# #o;
# Time: 12:00 or 12:00:00 with optional am/pm
return unless $dtstr =~ /\S/;
Expand Down
16 changes: 15 additions & 1 deletion t/cpanrt.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use Date::Format qw(time2str);
use Date::Parse qw(strptime);

print "1..4\n";
print "1..5\n";

my $i = 1;

Expand All @@ -27,3 +27,17 @@ my $i = 1;
}
}

{ # RT#17396: Parse error for french date with 'mars' (march) as month
use Date::Language;
my $dateP = Date::Language->new('French');
my $timestamp = $dateP->str2time('4 mars 2005');
my ($ss, $mm, $hh, $day, $month, $year, $zone) = localtime $timestamp;
$month++;
$year += 1900;
my $date = "$day/$month/$year";
print "# $date\n";
print "not " unless $date eq "4/3/2005";
print "ok ", $i++, "\n";
}


0 comments on commit 6159051

Please sign in to comment.