moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.23k stars 730 forks source link

React Native Android hermes toFormat("ZZZZ") #1471

Closed jamesholcomb closed 1 year ago

jamesholcomb commented 1 year ago

Describe the bug In React Native 0.72.3 Android with Hermes, toFormat with "ZZZZ" outputs as an offset to GMT.

On iOS Hermes, toFormat works as expected and returns the abbreviated timezone name.

Reproduced on device (Samsung S10e) and emulator (Android API 33).

Perhaps this is an issue with Hermes, but my searches could not turn up any related info.

To Reproduce

// logging from metro in an RN app... current locale is en-US but being specific here.
const zone = DateTime.now().toFormat("ZZZZ", { locale: "en-US" })
console.log("zone", zone) // on Android: GMT-5, on iOS: CDT

Actual vs Expected behavior abbreviated named offset of CDT

Desktop (please complete the following information):

Additional context

npx react-native info
System:
  OS: macOS 12.6.6
  CPU: (10) arm64 Apple M1 Max
  Memory: 158.05 MB / 32.00 GB
  Shell:
    version: 5.8.1
    path: /bin/zsh
Binaries:
  Node:
    version: 18.16.0
    path: ~/.nvm/versions/node/v18.16.0/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v18.16.0/bin/yarn
  npm:
    version: 9.5.1
    path: ~/.nvm/versions/node/v18.16.0/bin/npm
  Watchman:
    version: 2023.05.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.1
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.2
      - iOS 16.2
      - macOS 13.1
      - tvOS 16.1
      - watchOS 9.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.1 AI-221.6008.13.2211.9477386
  Xcode:
    version: 14.2/14C18
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.17
    path: /usr/bin/javac
  Ruby:
    version: 2.7.7
    path: /Users/jamesholcomb/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.3
    wanted: 0.72.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
jamesholcomb commented 1 year ago

As I suspected, it does appear to be a Hermes bug

https://github.com/facebook/hermes/issues/661

diesieben07 commented 1 year ago

Considering this is an issue with the runtime and not Luxon, I am going to close this issue. Luxon does not ship its own locale data, but relies on the underlying JavaScript runtime (Hermes in this case) to have a correct Intl.DateTimeFormat implementation.