Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__setDefaultTimeZone does not handle "Etc/UTC" timezone #2951

Closed
dlebedynskyi opened this issue Jun 4, 2021 · 0 comments
Closed

__setDefaultTimeZone does not handle "Etc/UTC" timezone #2951

dlebedynskyi opened this issue Jun 4, 2021 · 0 comments
Labels

Comments

@dlebedynskyi
Copy link

Which package?

@formatjs/intl-datetimeformat

Describe the bug

__setDefaultTimeZone can not handle timezone passed as "Etc/UTC" and throws "Invalid timeZoneName" errror.
Root case -

!IsValidTimeZoneName(timeZone, {
does not handle "Etc/UTC" code same way as
if (ianaTimeZone === 'Etc/UTC' || ianaTimeZone === 'Etc/GMT') {
does.

Since IsValidTimeZoneName is called before CanonicalizeTimeZoneName can convert "Etc/UTC" to UTC, error is thrown.

To Reproduce

Issue is reproducible on Android devices in React Native App

  • Setup your Android device to UTC +0 (for API 29-30 disable timezone from network, manually select UTC offset instead of region & city)
  • call with TZ from device
 DateTimeFormat.__setDefaultTimeZone(tz)// "Etc/UTC"

Codesandbox URL

 DateTimeFormat.__setDefaultTimeZone("Etc/UTC") // will throw

Expected behavior

It is expected that UTC timezone would be selected, based on

if (ianaTimeZone === 'Etc/UTC' || ianaTimeZone === 'Etc/GMT') {
.

Screenshots

N/A

Desktop (please complete the following information):

  • OS: Android
  • Version API 29, 30

Smartphone (please complete the following information):

  • Device: any Android device
  • OS: API 29, 30

Additional context

While IsValidTimeZoneName is by the spec - https://tc39.es/ecma402/#sec-isvalidtimezonename, it seems it does not account for "Etc/UTC" to "UTC" conversion, same way as

if (ianaTimeZone === 'Etc/UTC' || ianaTimeZone === 'Etc/GMT') {
does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant