Subject: | [Patch] Better heuristic (maybe) for Mac OS X in Brazil |
Under Mac OS X (uname output appended) Date::Manip seems to end up deriving the Olson zone by a lookup on the results of 'date +%Z'. In Sao Paulo in June, this gives 'BRT'. Given the structure of the lookup table, this ends up as 'America/Araguaina'. This is fine as far as it goes, but Araguaina is up near the Equator, and does not do summer time. This is OK for times near the current time, but times in (say) January) parse an hour off.
Now, it appears to me that the look-up table for 'BRST' has been juggled to put Sao Paulo at the top. The attached patch performs the same juggling act for 'BRT'. I am a GitHub neophyte, but will generate a pull request as soon as I can figure out how.
Note that this does not truly fix the problem, it just makes the results consistent, and moves the locations where the default parse is incorrect from a more-populous area to a less-populous one.
What is really needed is a way to derive the Olson zone directly. DateTime::TimeZone does it (at least, under Mac OS X) by looking for symbolic link /etc/localtime and deriving the name of the Olson zone from the name of the file the link points to. After I get the pull request for this ticket generated, I will try to come up with an enhancement to add this functionality to Date::Manip.
$ uname -a
Darwin Hairy-Toes.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
$ perl -v
This is perl 5, version 22, subversion 0 (v5.22.0) built for darwin-2level
...
$ perl -MDate::Manip -E 'say Date::Manip->VERSION'
6.50
The patch is against commit cdc16eeeb1e2688d6fb025490747da518caec27f
Subject: | Date-Manip.patch |
diff --git a/lib/Date/Manip/Zones.pm b/lib/Date/Manip/Zones.pm
index 707289f..433ca9f 100644
--- a/lib/Date/Manip/Zones.pm
+++ b/lib/Date/Manip/Zones.pm
@@ -1901,13 +1901,13 @@ $LastYear = '2065';
'america/maceio',
'america/recife',
'america/belem' ],
- 'brt' => [ 'america/araguaina',
+ 'brt' => [ 'america/sao_paulo',
+ 'america/araguaina',
'america/bahia',
- 'america/belem',
'america/fortaleza',
'america/maceio',
'america/recife',
- 'america/sao_paulo',
+ 'america/belem',
'america/santarem' ],
'bst' => [ 'europe/london',
'america/adak',
diff --git a/t/tz.define_abbrev.t b/t/tz.define_abbrev.t
index a38475b..4641c28 100755
--- a/t/tz.define_abbrev.t
+++ b/t/tz.define_abbrev.t
@@ -26,13 +26,13 @@ $obj->config("forcedate","now,America/New_York");
$tests="
BRT reset =>
+ America/Sao_Paulo
America/Araguaina
America/Bahia
- America/Belem
America/Fortaleza
America/Maceio
America/Recife
- America/Sao_Paulo
+ America/Belem
America/Santarem
BRT