Android Intl doesn't work as expected
See original GitHub issueIssue Description
To start, I’ve created a small repro here: https://github.com/deecewan/TimeZoneTest
I set up a brand new project (npx react-native-cli init TimeZoneTest
), and then followed the steps for React Native 0.59, and added the support for Intl. This works, because the Intl object actually exists now (yay!).
The problem is, the behaviour is not the same as on iOS when trying to format dates.
Here is the output on Android:
And the same code on iOS:
The same code on Android, with remote debug enabled:
(Note: My android emulator is set up to be in Australia/Brisbane. The iOS Simulator is set to my laptop’s TZ, in Canada. In remote debug, it uses Chrome in my laptop’s TZ).
As you can see, when formatting on the iPhone and in Chrome via Remote Debugging, the output is in the TZ of the ‘device’. When rendering on Android, with Intl enabled, it renders in UTC/GMT. This seems to be inconsistent with how it should be rendering.
Version, config, any additional info
See repro reop for full details
React Native 0.59.8
jsc-android: 241213.x.x
android/app/build.gradle dep: implementation "org.webkit:android-jsc-intl:r241213"
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:11 (4 by maintainers)
I can confirm that this issue still exists (I’m using FormattedTime component from react-intl) and in Android version I have the same problem related with UTC zones, while iOS works correctly.
Spent a couple of hours trying to install different sets of polyfills for react-intl I’ve found a working solution. For someone looking for fix - instead of default installation please use
yarn add jsc-android@npm:@kudo-ci/jsc-android
Many thanks to @Kudo for this. I cannot understand why his MR with fix is still in review (since September of 2019)… Dear maintainers, could you please pay more attention to this?
Thank you for the briefly explanation. I’ve confirm it is an issue and root cause is that IntlDateTimeFormat use ICU’s
ucal_getDefaultTimeZone
to query current timezone. And it is not integrate to Androidpersist.sys.timezone
https://github.com/WebKit/webkit/blob/master/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp#L126 Need to patch handy.