Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Etc/GMT+4 is wrong (as are all Etc/GMT+/-) #47

Closed
wolfsage opened this issue Dec 15, 2020 · 6 comments
Closed

Etc/GMT+4 is wrong (as are all Etc/GMT+/-) #47

wolfsage opened this issue Dec 15, 2020 · 6 comments

Comments

@wolfsage
Copy link
Contributor

The Etc/GMT time_zones are backwards in newer DateTimes.

Here's an older DateTime (1.12) / DateTime::TimeZone (2.36), which is correct:

perl -MDateTime -e 'print "Now:   " . DateTime->now . "\nGMT+4: " . DateTime->now(time_zone=> "Etc/GMT+4") . "\n"'
Now:   2020-12-15T14:14:03
GMT+4: 2020-12-15T10:14:03

Here's a newer DateTIme (1.50) / DateTime::TimeZone (2.44), which has it backwards:

perl -MDateTime -e 'print "Now:   " . DateTime->now . "\nGMT+4: " . DateTime->now(time_zone=> "Etc/GMT+4") . "\n"'
Now:   2020-12-15T14:15:45
GMT+4: 2020-12-15T18:15:45

From https://data.iana.org/time-zones/tzdb/etcetera:

# Be consistent with POSIX TZ settings in the Zone names,
# 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 "-04" 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).

# Earlier incarnations of this package were not POSIX-compliant,
# and had lines such as
#		Zone	GMT-12		-12	-	GMT-1200
# We did not want things to change quietly if someone accustomed to the old
# way does a
#		zic -l GMT-12
# so we moved the names into the Etc subdirectory.
@autarch autarch transferred this issue from houseabsolute/DateTime.pm Dec 20, 2020
@autarch
Copy link
Member

autarch commented Dec 20, 2020

I moved this to the DateTime-TimeZone repo, since that's where the code to handle these zones lives.

@autarch
Copy link
Member

autarch commented Dec 21, 2020

I'm not sure how this worked for you with an older DT::TZ. Here's what I get with DateTime 1.12 and DateTime::TimeZone 2.36:

> perl -MDateTime -e 'print "Now:   " . DateTime->now . "\nGMT+4: " . DateTime->now(time_zone=> "Etc/GMT+4") . "\n"'
The timezone 'Etc/GMT+4' could not be loaded, or is an invalid name.

@wolfsage
Copy link
Contributor Author

DateTime::TimeZone finds the following file:

# This file is auto-generated by the Perl DateTime Suite time zone
# code generator (0.08) This code generator comes with the
# DateTime::TimeZone module distribution in the tools/ directory

#
# Generated from /tmp/ZbFw0zNOVB/etcetera.  Olson data version 2019b
#
# Do not edit this file directly.
#
package DateTime::TimeZone::Etc::GMT_Plus4;

use strict;
use warnings;
use namespace::autoclean;

our $VERSION = '2.36';

use Class::Singleton 1.03;
use DateTime::TimeZone;
use DateTime::TimeZone::OlsonDB;

@DateTime::TimeZone::Etc::GMT_Plus4::ISA = ( 'Class::Singleton', 'DateTime::TimeZone' );

my $spans =
[
    [
DateTime::TimeZone::NEG_INFINITY, #    utc_start
DateTime::TimeZone::INFINITY, #      utc_end
DateTime::TimeZone::NEG_INFINITY, #  local_start
DateTime::TimeZone::INFINITY, #    local_end
-14400,
0,
'-04',
    ],
];

sub olson_version {'2019b'}

sub has_dst_changes {0}

sub _max_year {2029}

sub _new_instance {
    return shift->_init( @_, spans => $spans );
}



1;

@wolfsage
Copy link
Contributor Author

Looks like we manually build our DateTime::TimeZone files with tools/parse_olson using --old

@autarch
Copy link
Member

autarch commented Dec 21, 2020

Looks like we manually build our DateTime::TimeZone files with tools/parse_olson using --old

That explains it.

@autarch
Copy link
Member

autarch commented Dec 21, 2020

Fixed in v2.45.

@autarch autarch closed this as completed Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants