question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android Intl doesn't work as expected

See original GitHub issue

Issue 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:

image

And the same code on iOS:

image

The same code on Android, with remote debug enabled:

image

(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:open
  • Created 4 years ago
  • Reactions:5
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
great-timofeycommented, Jul 27, 2020

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?

2reactions
Kudocommented, May 16, 2019

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 Android persist.sys.timezone https://github.com/WebKit/webkit/blob/master/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp#L126 Need to patch handy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intl.numberformat in React native works fine when running in ...
I am developing an app with React Native to run on IOS and Android. I use Intl.numberformat() to print currency, and it works...
Read more >
Intl.Locale() constructor - JavaScript - MDN Web Docs
The Intl.Locale constructor is a standard built-in property of the Intl object that represents a Unicode locale identifier.
Read more >
Switch to Android
And Google apps that work smarter together. It's easy to move from ... If you don't have a Google Account, you can create...
Read more >
Contact an Android app's developer - Google Play Help
On Android mobile devices. Open the Google Play Store app Google Play . Browse or search for the app. ... What to expect...
Read more >
Can't call, dropped calls, & other calling issues - T-Mobile
Touch tones don't work · Turn on touch tones in your phone settings. Note that touch tones may not work if you're on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found