DateTime::Format::Strptime version 0.0702 (and earlier) incorrectly
processes the Olson time zone string

  America/New_York

into

  America/New_york

which then correctly fails to produce a TimeZone object.

This patch tests for the condition and provides a fix in the module.

-kolibrie

Thu Sep 27 14:42:54 EDT 2007  [EMAIL PROTECTED]
  * allow Olson Time zone 'America/New_York' to parse
diff -rN -u old-DateTime-Format-Strptime/lib/DateTime/Format/Strptime.pm new-DateTime-Format-Strptime/lib/DateTime/Format/Strptime.pm
--- old-DateTime-Format-Strptime/lib/DateTime/Format/Strptime.pm	2007-09-27 14:46:19.000000000 -0400
+++ new-DateTime-Format-Strptime/lib/DateTime/Format/Strptime.pm	2007-09-27 14:46:19.000000000 -0400
@@ -330,7 +330,7 @@
 
 	if ($tz_olson) {
 		$tz_olson = ucfirst lc $tz_olson;
-		$tz_olson =~ s|([/_])(\w)|$1\U$2|;
+		$tz_olson =~ s|([/_])(\w)|$1\U$2|g;
 		my $tz = DateTime::TimeZone->new( name => $tz_olson );
 		$self->local_croak("I don't recognise the time zone '$tz_olson'.") and return undef unless $tz;
 		$use_timezone = $set_time_zone = $tz;
diff -rN -u old-DateTime-Format-Strptime/t/007_edge.t new-DateTime-Format-Strptime/t/007_edge.t
--- old-DateTime-Format-Strptime/t/007_edge.t	2007-09-27 14:46:19.000000000 -0400
+++ new-DateTime-Format-Strptime/t/007_edge.t	2007-09-27 14:46:19.000000000 -0400
@@ -2,7 +2,7 @@
 
 # t/007_edge.t - these tests are for edge case bug report errors
 
-use Test::More tests => 10;
+use Test::More tests => 15;
 use DateTime;
 use DateTime::Format::Strptime;
 
@@ -43,6 +43,19 @@
 	is($parsed->epoch,'1131143580', 'Time zone applied to string');
 }
 
+# Olson Time Zone munging does not corrupt New_York
+{
+	my $parser = DateTime::Format::Strptime->new(
+		pattern   => '%F %T %O',
+		on_error  => 'undef',
+	);
+	isa_ok($parser, 'DateTime::Format::Strptime');
+	my $parsed = $parser->parse_datetime('2004-12-14 16:25:15 America/New_York');
+	isa_ok($parsed, 'DateTime');
+	is($parsed->datetime,'2004-12-14T16:25:15', 'Date and time have not drifted');
+	is($parsed->time_zone->name,'America/New_York', 'Time zone determined from string');
+	is($parsed->epoch,'1103059515', 'Time zone applied to string');
+}
 
 
 sub test {

Attachment: signature.asc
Description: Digital signature

Reply via email to