moment / moment-timezone

Timezone support for moment.js
momentjs.com/timezone
MIT License
3.83k stars 838 forks source link

Czechia and Slovakia timezone mixup #1066

Open nexpid opened 1 year ago

nexpid commented 1 year ago

Environment

in data/packed/latest.json, timezones Europe/Prague and Europe/Bratislava are marked as the same timezone:

https://github.com/moment/moment-timezone/blob/f7d8fc2d42a832b390c3f770ec5d52b4803a1a14/data/packed/latest.json#L572

country code SK includes Europe/Prague (incorrect) and Europe/Bratislava (correct):

https://github.com/moment/moment-timezone/blob/f7d8fc2d42a832b390c3f770ec5d52b4803a1a14/data/packed/latest.json#L803

Issue description

As mentioned above, country code SK also includes Europe/Prague, even though Prague is in Czechia, not Slovakia. image

Running this code in the latest version of moment-timezone also yields wrong results:

moment.tz.zonesForCountry("CZ"); // => [ "Europe/Prague" ] (✅)

moment.tz.zonesForCountry("SK"); // => [ "Europe/Bratislava", "Europe/Prague" ] (❌)
gilmoreorless commented 1 year ago

This is a similar issue to #1005, and I'll tweak my comment from there.

The data comes from the IANA time zone database (tzdb). There have been some changes with recent releases of tzdb, where time zones that have the same data since 1970 have been merged together, even if they're in different countries. This has definitely caused some confusion here and in other software projects.

The important thing is that identifiers like Europe/Prague are labels for regions of the world where the clocks agree. The country data you've quoted is not saying that Prague is in Slovakia. It's saying that the time in Slovakia can be represented by a time zone that happens to have the label Europe/Prague.

This can be seen in the tzdb source zone1970.tab:

CZ,SK +5005+01426 Europe/Prague

That line says that Czechia and Slovakia can both be represented by the same time zone rules. This would be equally true if the labels didn't have city names at all, but instead were named something like Europe/Zone073.

Note that Europe/Bratislava doesn't appear in that zone1970.tab file, because it's just a backwards-compatibility link to Europe/Prague. Moment Timezone adds the compatibility links to the country lists as well, based on the older (and deprecated) zone.tab.

I know this is a confusing situation. I'm going to leave this issue open as a reminder to write some proper documentation about it on the momentjs.com site.