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

Intl.DateTimeFormat() returns short timeZoneName with GMT offset removed in some locales #1601

Open
2 tasks done
kueda opened this issue Jan 24, 2025 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working

Comments

@kueda
Copy link

kueda commented Jan 24, 2025

Bug Description

Intl.DateTimeFormat() returns short timeZoneName with GMT offset removed in some locales.

  • I have run gradle clean and confirmed this bug does not occur with JSC
  • The issue is reproducible with the latest version of React Native.

Hermes git revision (if applicable):
React Native version: 0.77.0
OS: iOS 18.2.1
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): running on iPhone, so I guess one of the arm ones

Steps To Reproduce

Intl.DateTimeFormat(
  "en-GB",
  { timeZone: "Pacific/Honolulu", timeZoneName: "short" }
)
  .formatToParts( new Date( ) )
  .find( p => p.type === "timeZoneName" ).value

gives the following output

GMT

The Expected Behavior

GMT-10

FWIW, I see the correct output in Android 14, and by "correct" I mean the output I see in Firefox and Chrome, GMT-10 (I would expect it to be HST like it is in en-US, but an accurate offset seems preferable to an inaccurate short name).

I am pretty sure this is just due to formatToParts() behaving a bit differently. The - and 10 are in subsequent parts as literal and year elements. That's just not how the method behaves in a browser.

Related: marnusw/date-fns-tz#306

@kueda kueda added the bug Something isn't working label Jan 24, 2025
@neildhar
Copy link
Contributor

Hey @kueda, the formatToParts implementation on iOS is unfortunately known to have major issues, which cannot easily be fixed. While we continue to provide it for backwards compatibility, we advise against using it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants