Issues

Issue #61 resolved

Change/Remove 'Etc' timezones for maximum compatibility

Jordan Magnuson
created an issue

Looking over the code, it appears that there are four possible return options beginning with 'Etc/':

  • Etc/GMT+12
  • Etc/GMT+2
  • Etc/GMT+2
  • Etc/UTC

These do not appear to be valid IANA timezone IDs. Checking the list at http://en.wikipedia.org/wiki/List_of_tz_database_time_zones , the only IDs that begin with 'Etc' are UTC synonyms, and 'UTC' seems to be the preferred default to 'Etc/UTC' ('Etc/UTC' is not valid in PHP, for instance, but 'UTC' is).

I'm working in PHP, and none of these 'Etc' IDs are recognized as valid zones, which leads to errors. See the supported list of PHP timezones at http://www.php.net/manual/en/timezones.php

Is there any reason why these return values cannot be replaced with valid IANA values?

Since this script says that "The return value is an IANA zone info key" I'm going to file this as a bug report, pending further clarification.

Comments (11)

  1. Jon Nylander repo owner

    Yet again, thank you!

    Working in Python using the "pytz" library I have not come across any problem using Etc/* zones.

    >>> import pytz
    >>> tz = pytz.timezone("Etc/GMT+2")
    >>> tz.zone
    'Etc/GMT+2'
    >>> localized = tz.localize(datetime(2012,12,12,5,3,2))
    datetime.datetime(2012, 12, 12, 5, 3, 2, tzinfo=<StaticTzInfo 'Etc/GMT+2'>)
    >>> utc = localized.astimezone(pytz.utc)
    datetime.datetime(2012, 12, 12, 7, 3, 2, tzinfo=<UTC>)
    

    I.e it works with pytz, which as far as I am aware bases itself on IANA. But I see no reason to replace those timezones with more established and PHP friendly ones. But it is not exactly trivial to know which IANA timezone represents UTC-2 (Mid atlantic) other than Etc/GMT+2.

    I'll investigate.

  2. Jordan Magnuson reporter

    Note the warning on the bottom of http://www.php.net/manual/en/timezones.others.php:

    "Please do not use any of the timezones listed here (besides UTC), they only exist for backward compatible reasons."
    

    timezone_identifiers_list() in php 5.3 does not return any 'Etc/*' timezones.

    Here's fresh output from that function (I'm running fully updated php 5.3): http://pastebin.com/6NKrARTG

    I believe you that the Wikipedia list may not be complete with regards to IANA, but even if it's not, and 'Etc/*' timezones are valid, the question becomes one of maximum compatibility.

    For further consideration, I did a bit of digging around in the Drupal core code, and Drupal (latest 7.x) actually has a block against accepting 'Etc/*' zones:

        // Because many time zones exist in PHP only for backward compatibility
        // reasons and should not be used, the list is filtered by a regular
        // expression.
        if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) {
          $zones[$zone] = t('@zone: @date', array('@zone' => t(str_replace('_', ' ', $zone)), '@date' => format_date(REQUEST_TIME, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone)));
        }
    

    When trying to load one of the Etc/* timezones in Drupal I receive errors (predictably).

    I submit for your consideration what I've discovered so far, that Etc/* zones:

    1. Are not listed on Wikipedia
    2. Are not returned by php's timezone_identifiers_list()
    3. Are not accepted by Drupal

    Seems like enough data to warrant a change?

  3. Jordan Magnuson reporter

    Did a bit more digging, and the Wikipedia page does seem to be a complete list of the IANA tz database version 2012c (which is linked from the page). The only zones they leave out, as far as I can tell, are precisely the 'Etc/*' zones, which is apparently an intentional omission based on this indication from the IANA 2012c 'etcetera' database file:

    # These entries are mostly present for historical reasons, so that
    # people in areas not otherwise covered by the tz files could "zic -l"
    # to a time zone that was right for their area.  These days, the
    # tz files cover almost all the inhabited world, and the only practical
    # need now for the entries that are not on UTC are for ships at sea
    # that cannot use POSIX TZ settings.
    

    It seems that the etc/* zones are being phased out, which is why php and Drupal no longer accept them...

  4. Jon Nylander repo owner

    I don't know what to say. A million thanks for taking the time to convince me. I stand corrected and will find suitable replacements for the Etc/* zones in the 1.0.5 release.

    /Jon

  5. Jordan Magnuson reporter

    Thanks Jon. And thanks for this tremendous library! Have started using a sandbox version on my site, and it's working like a charm (minus the Etc zones, which I'm filtering out). There was no end to timezone confusion previously when users were asked to set their zones manually, so this has been a real boon.

  6. Log in to comment