Skip Menu |

This queue is for tickets about the Time-Zone-Olson CPAN distribution.

Report information
The Basics
Id: 118011
Status: resolved
Priority: 0/
Queue: Time-Zone-Olson

People
Owner: Nobody in particular
Requestors: andreas.guldstrand [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.12



Subject: Using Etc/GMT-1 or Etc/GMT+1 and similar timezones
Date: Wed, 21 Sep 2016 12:48:50 +0200
To: bug-Time-Zone-Olson [...] rt.cpan.org
From: Andreas Guldstrand <andreas.guldstrand [...] gmail.com>
These timezones exist on my system and I would like to use Time::Zone::Olson to parse them, but whenever I try I get errors. The first error I get is when I try to use Etc/GMT+1 like so: perl -MTime::Zone::Olson -E ' say Time::Zone::Olson->new({timezone => "Etc/GMT+1"})->local_offset(time)' Output: 'Etc/GMT+1' does not have a valid format for a TZ timezone at -e line 1. It's as if it can't find the file even though I can see it's there. If I try to use Etc/GMT-1 I get a slightly different error: perl -MTime::Zone::Olson -E ' say Time::Zone::Olson->new({timezone => "Etc/GMT-1"})->local_offset(time)' Output: Failed to parse the tz defintion of <GMT-1>-1 from /usr/share/zoneinfo/Etc/GMT-1 at -e line 1. I really like what this module is doing, so if I can be of any help don't hesitate to ask. Thank you / Andreas
Interesting. Can you try the attached patch and see if that produces the desired results? On my system, this produces the following results; $ TZ='<GMT-10>-10' date Wed Sep 21 22:01:21 GMT-10 2016 $ perl -Ilib -MTime::Zone::Olson -E ' say "" . Time::Zone::Olson->new({timezone => "Etc/GMT-10"})->local_time(time)' Wed Sep 21 22:07:33 2016
Subject: rt118011.patch
diff -Naur old/lib/Time/Zone/Olson.pm new/lib/Time/Zone/Olson.pm --- old/lib/Time/Zone/Olson.pm 2016-04-16 13:45:04.000000000 +1000 +++ new/lib/Time/Zone/Olson.pm 2016-09-21 21:59:09.667984557 +1000 @@ -66,7 +66,7 @@ sub _DEFAULT_DST_END_HOUR { return 2 } sub _TIMEZONE_FULL_NAME_REGEX { - return qr/(?<area>\w+)(?:\/(?<location>[\w\-\/]+))?/smx; + return qr/(?<area>\w+)(?:\/(?<location>[\w\-\/+]+))?/smx; } my $_default_zoneinfo_directory = '/usr/share/zoneinfo'; @@ -1255,7 +1255,7 @@ sub _parse_tz_variable { my ( $self, $tz_variable, $path ) = @_; my $timezone_abbr_name_regex = - qr/(?:[^:\d,+-][^\d,+-]{2,}|[<][+-]?\d+[>])/smx; + qr/(?:[^:\d,+-][^\d,+-]{2,}|[<]\w*[+-]?\d+[>])/smx; my $std_name_regex = qr/(?<std_name>$timezone_abbr_name_regex)/smx ; # Name for standard offset from GMT my $std_sign_regex = qr/(?<std_sign>[+-])/smx;
Subject: Re: [rt.cpan.org #118011] Using Etc/GMT-1 or Etc/GMT+1 and similar timezones
Date: Wed, 21 Sep 2016 14:32:45 +0200
To: bug-Time-Zone-Olson [...] rt.cpan.org
From: Andreas Guldstrand <andreas.guldstrand [...] gmail.com>
Yes, this patch seems to work perfectly. Thanks for the quick response! =) On 21 September 2016 at 14:08, David Dick via RT <bug-Time-Zone-Olson@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=118011 > > > Interesting. Can you try the attached patch and see if that produces the desired results? > > On my system, this produces the following results; > > $ TZ='<GMT-10>-10' date > Wed Sep 21 22:01:21 GMT-10 2016 > > $ perl -Ilib -MTime::Zone::Olson -E ' say "" . Time::Zone::Olson->new({timezone => "Etc/GMT-10"})->local_time(time)' > Wed Sep 21 22:07:33 2016