mde / timezone-js

DEPRECATED: Timezone-enabled JavaScript Date object. Uses Olson zoneinfo files for timezone data.
824 stars 183 forks source link

Invalid region for some timezones #157

Closed rem11 closed 4 years ago

rem11 commented 10 years ago

When I call timezoneJS.timezone.getRegionForTimezone() for example, for "America/Dominica" it returns "northamerica", but "America/Dominica" is defined in "southamerica" TZ file. That leads to incorrect TZ file loading and inability to format date.

JamieRuderman commented 9 years ago

I'm having the same issue with America/St_Thomas. The root cause seems to be that when using the LAZY_LOAD loadingScheme, the 'America' prefix of these timezones causes timezoneJS to load the northamerica file, when in fact they are in the southamerica files.

As a workaround I'm loading both by default:

timezoneJS.timezone.defaultZoneFile = ['northamerica', 'southamerica'];

I understand that it might not be feasible to detect southamerica from these timezones, but I would suggest in the case that LAZY_LOAD is enabled that both south and north america are loaded if a timezone has America as the prefix.

mde commented 9 years ago

This sounds totally reasonable. Could you give us a pull request?

JamieRuderman commented 9 years ago

So in digging a little deeper into the code I noticed that there is already a long list of zone file region exceptions that have been handling all the southamerica timezones. Unfortunately it needs to be updated along with olsen file changes and it's become out of sync.

I have a fix to do the loading of ['northamerica', 'southamerica'] files for the 'America' region. Which if I add, I could then remove all the southamerica region exceptions, but perhaps I should just update the exceptions list.

Let me know what you'd prefer. Thanks!

mde commented 9 years ago

Probably better if we don't need to keep things in sync with the Olson data. Let's load it by default and remove all the exceptions.