manuelmhtr / countries-and-timezones

Minimalistic library to work with countries and timezones data
MIT License
224 stars 67 forks source link

Reversed UTC offsets for GMT timezones #47

Closed nick-keller closed 2 years ago

nick-keller commented 2 years ago

Issue

Hello, It looks like the UTC offset of GMT timezones is reversed:

{
  "timezones": {
    "Etc/GMT+10": {
      "u":-600
    }
  }
}

Expected result

Here I would expect u to be 600 not -600 since the timezone is Etc/GMT+10 not Etc/GMT-10.

Why I believe this is a mistake

From this, I come to the conclusion that GMT+2 has an offset of 120. I might me missing something so feel free to correct me.

manuelmhtr commented 2 years ago

Hi @nick-keller, It's very counter intuitive but Etc/GMT+10 is actually -600 minutes away from GMT. What you are referring is UTC/GMT+10.

You are right Europe/Paris is GMT+2 (+120 from GMT), but the Etc at the beginning is a special area that indicates west zone of GMT will have a positive sign and east zone a negative sign. That is, their sign in inverted.

You can check their definition here.

In order to conform with the POSIX style, those zone names beginning with "Etc/GMT" have their sign reversed from the standard ISO 8601 convention. In the "Etc" area, zones west of GMT have a positive sign and those east have a negative sign in their name (e.g "Etc/GMT-14" is 14 hours ahead of GMT).

You can also confirm it here and here.

Hope this info helps!

nick-keller commented 2 years ago

That makes perfect sense, thanks @manuelmhtr. Then I am surprised we don't have UTC/GTM+X timezones in the set, but I assume it is not part of the official list.

Thanks a lot for the package!