Subject: | UTC is missing in the list of timezones |
DateTime::Format::StrpTime fails on parsing dates like
Thu Jul 8 23:59:16 CEST 2010
when the timezone is UTC, i.e.:
$ TZ= date
Thu Jul 8 22:00:18 UTC 2010
This is because 'UTC' is missing in %ZONEMAP. The attached patch fixes
this.
Subject: | strptime.patch |
# HG changeset patch
# User Danijel Tasov <data@cpan.org>
# Date 1278626041 -7200
# Node ID 09bcfaabcb1bb39e61cbee7f9c2230e12f319a9c
# Parent 2725b903314dbc4cb01b5b6c4478fb7f717cba74
Added UTC to the list of known time zones.
Also created a test to make sure it is never forgotten again.
diff -r 2725b903314d -r 09bcfaabcb1b .hgignore
--- a/.hgignore Mon Jun 28 11:48:13 2010 -0500
+++ b/.hgignore Thu Jul 08 23:54:01 2010 +0200
@@ -16,3 +16,4 @@
Makefile.old
pm_to_blib*
DateTime-Format-Strptime-*
+.build
diff -r 2725b903314d -r 09bcfaabcb1b lib/DateTime/Format/Strptime.pm
--- a/lib/DateTime/Format/Strptime.pm Mon Jun 28 11:48:13 2010 -0500
+++ b/lib/DateTime/Format/Strptime.pm Thu Jul 08 23:54:01 2010 +0200
@@ -120,6 +120,7 @@
'Y' => '-1200', 'YAKST' => '+1000', 'YAKT' => '+0900',
'YAPT' => '+1000', 'YDT' => '-0800', 'YEKST' => '+0600',
'YEKT' => '+0500', 'YST' => '-0900', 'Z' => '+0000',
+ 'UTC' => '+0000',
);
sub new {
diff -r 2725b903314d -r 09bcfaabcb1b t/008_epoch.t
--- a/t/008_epoch.t Mon Jun 28 11:48:13 2010 -0500
+++ b/t/008_epoch.t Thu Jul 08 23:54:01 2010 +0200
@@ -2,7 +2,7 @@
# t/008_epoch.t - Epoch (%s) tests
-use Test::More tests => 23;
+use Test::More tests => 26;
use DateTime;
use DateTime::Format::Strptime;
@@ -17,6 +17,15 @@
epoch => $time,
);
+# is UTC recognized?
+test(
+ pattern => "%a %d %b %Y %H:%M:%S %p %Z",
+ time_zone => 'UTC',
+ locale => 'en_US',
+ input => "Thu 08 Jul 2010 09:49:02 AM UTC",
+ epoch => 1278582542,
+);
+
# diag("Epoch with a no given time_zone assumes 'floating'. (Though when given an epoch, really should assume UTC ..)");
{
my $parser = DateTime::Format::Strptime->new(