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 support polyfill fails to load timezones on Android on 0.59.10 #25595

Closed
bramski opened this issue Jul 11, 2019 · 7 comments
Closed

Intl support polyfill fails to load timezones on Android on 0.59.10 #25595

bramski opened this issue Jul 11, 2019 · 7 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@bramski
Copy link

bramski commented Jul 11, 2019

Intl polyfill has stopped working on 0.59.10, after upgrading we found our app was producing Invalid DateTime for all timezone related strings on Android.

Diving more deeply, the following code crashes:
Intl.DateTimeFormat("en-US", { timeZone: 'America/New_York' }).format()
and produces
RangeError: timeZone is not supported

Package.json includes:

"intl": "^1.2.5",

and Root.js has:

import 'intl';
import 'intl/locale-data/jsonp/en';
import 'intl/locale-data/jsonp/de';
import 'intl/locale-data/jsonp/fr';

React Native version:
info
React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 834.63 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 11.12.0 - /usr/local/bin/node
Yarn: 1.16.0 - ~/.yarn/bin/yarn
npm: 6.10.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 22, 23, 24, 25, 26, 27, 28
Build Tools: 22.0.1, 24.0.0, 27.0.3, 28.0.3, 29.0.0
System Images: android-24 | Android TV Intel x86 Atom, android-24 | Intel x86 Atom, android-24 | Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: ^0.59.10 => 0.59.10
npmGlobalPackages:
create-react-native-app: 0.0.6
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Steps To Reproduce

  1. install intl polyfill
  2. add import 'intl' to your Root.js
  3. call Intl.DateTimeFormat("en-US", { timeZone: 'America/New_York' }).format()

Describe what you expected to happen:
App should not crash on lookup of the timezone string.

@bramski bramski added the Bug label Jul 11, 2019
@bramski
Copy link
Author

bramski commented Jul 11, 2019

Linked issue in Luxon: moment/luxon#541

@react-native-bot react-native-bot added the Platform: Android Android applications. label Jul 11, 2019
@react-native-bot
Copy link
Collaborator

It looks like you are using an older version of React Native. Please update to the latest release, v0.60 and verify if the issue still exists.

The "Resolution: Old Version" label will be removed automatically once you edit your original post with the results of running `react-native info` on a project using the latest release.

@bramski
Copy link
Author

bramski commented Jul 11, 2019

I can't upgrade to 0.60 due to a whole host of issues affecting dependent packages. I do need to upgrade to 0.59 though for the 64 bit support which is due next month.

@bramski
Copy link
Author

bramski commented Jul 11, 2019

Ay carumba.
🤦‍♂
https://github.com/andyearnshaw/Intl.js/blob/master/src/12.datetimeformat.js#L196
Was Intl support working before on android?

@bramski
Copy link
Author

bramski commented Jul 11, 2019

As it turns out intl polyfill and associated are totally uneeded. I found buried in react-native-community (this wasn't listed in breaking issues!)
https://github.com/react-native-community/jsc-android-buildscripts#international-variant
I followed that guide and removed intl polyfill and all is well.

@bramski bramski closed this as completed Jul 11, 2019
@JonahElbaz
Copy link

https://www.npmjs.com/package/date-time-format-timezone

this helped me

@WilbertJanney
Copy link

WilbertJanney commented Mar 31, 2021

https://www.npmjs.com/package/date-time-format-timezone

this helped me

How did you import it into your app to make the Intl.DateTimeFormat method work for Android? When I tried importing it, I get an error that says that undefined is not an object (evaluating 'myGlobal.Intl.DateFormat')

@facebook facebook locked as resolved and limited conversation to collaborators Oct 9, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants