[libdatetime-timezone-perl] 06/13: Generate usable Etc/GMT+XX modules when "parse_olson --old" is run

gregor herrmann gregoa at debian.org
Wed Apr 15 19:03:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to annotated tag v1.76
in repository libdatetime-timezone-perl.

commit 5e691e347b7195c9de886db22443e9335a9d2c02
Author: Alfie John <alfiej at fastmail.fm>
Date:   Wed Aug 20 01:32:16 2014 +0000

    Generate usable Etc/GMT+XX modules when "parse_olson --old" is run
---
 lib/DateTime/TimeZone/OlsonDB/Observance.pm | 20 +++++++++++++++++++-
 tools/parse_olson                           | 13 +++++++++----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/lib/DateTime/TimeZone/OlsonDB/Observance.pm b/lib/DateTime/TimeZone/OlsonDB/Observance.pm
index 9fa807a..ae2a33f 100644
--- a/lib/DateTime/TimeZone/OlsonDB/Observance.pm
+++ b/lib/DateTime/TimeZone/OlsonDB/Observance.pm
@@ -25,7 +25,25 @@ sub new {
         }
     );
 
-    my $offset_from_utc = DateTime::TimeZone::offset_as_seconds( $p{gmtoff} );
+    my $offset_from_utc;
+
+    if ( $p{gmtoff} =~ /^([\+\-]?\d\d?)$/ ) {
+      # From the Olson database's etcetera file: 
+      #
+      # We use POSIX-style signs in the Zone names and the output
+      # abbreviations, even though this is the opposite of what many people
+      # expect. POSIX has positive signs west of Greenwich, but many people
+      # expect positive signs east of Greenwich.  For example, TZ='Etc/GMT+4'
+      # uses the abbreviation "GMT+4" and corresponds to 4 hours behind UT
+      # (i.e. west of Greenwich) even though many people would expect it to
+      # mean 4 hours ahead of UT (i.e. east of Greenwich).  
+
+      $offset_from_utc = 3600 * $1 * -1;
+    }
+    else {
+      $offset_from_utc = DateTime::TimeZone::offset_as_seconds( $p{gmtoff} );
+    }
+
     my $offset_from_std
         = DateTime::TimeZone::offset_as_seconds( $p{offset_from_std} );
 
diff --git a/tools/parse_olson b/tools/parse_olson
index c72627c..ec64197 100755
--- a/tools/parse_olson
+++ b/tools/parse_olson
@@ -166,10 +166,15 @@ sub parse_file {
             $name = $zone_name;
         }
 
-        ( my $outfile1 = $name ) =~ tr/-/_/;
-
-        ( my $mod_name = $zone_name ) =~ s/\//::/g;
-        $mod_name =~ tr/-/_/;
+        my $outfile1 =  $name;
+        $outfile1    =~ s/-(\d)/_Minus$1/;
+        $outfile1    =~ s/\+/_Plus/;
+        $outfile1    =~ s/-/_/g;
+
+        ( my $mod_name =  $zone_name ) =~ s/\//::/g;
+        $mod_name      =~ s/-(\d)/_Minus$1/;
+        $mod_name      =~ s/\+/_Plus/;
+        $mod_name      =~ s/-/_/g;
 
         my $zone     = $odb->zone($zone_name);
         my $max_year = max(

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdatetime-timezone-perl.git



More information about the Pkg-perl-cvs-commits mailing list