pytz question: GMT vs. UTC

Ben Finney ben+python at benfinney.id.au
Wed Jan 29 13:45:53 EST 2014


Skip Montanaro <skip at pobox.com> writes:

> According ato the pytz doc (http://pytz.sourceforge.net/):
>
> "‘UTC’ is Universal Time, also known as Greenwich Mean Time or GMT in
> the United Kingdom."

This is inaccurate, and I'd like to see it corrected in the
documentation. UTC is neither UT nor GMT.

GMT is not precisely defined, which makes it unsuitable for keeping
precise time in a computer system.

> If they are equal, why don't timezone objects created from those two
> strings compare equal?
>
> >>> pytz.timezone("UTC") == pytz.timezone("GMT")
> False

Python is correct, the timezones are not the same.

See <URL:https://en.wikipedia.org/wiki/Coordinated_Universal_Time> and
<URL:https://en.wikipedia.org/wiki/Greenwich_Mean_Time>. From the
former:

    Saying "GMT" often implies either UTC or UT1 when used within
    informal or casual contexts. In technical contexts, usage of "GMT"
    is avoided; the unambiguous terminology "UTC" or "UT1" is preferred.

> (I'm revealing my complete ignorance of timezone manipulation by
> asking this question.)

Treat GMT like any other locale-specific timezone, and convert to/from
it as late/early as possible (like a locale-specific encoding).

Treat UTC as the canonical timezone for keeping all timestamp values in
(like Unicode for text).

-- 
 \     “Reality must take precedence over public relations, for nature |
  `\                            cannot be fooled.” —Richard P. Feynman |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list