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 throws and RangeError "Invalid timezone name!" when valid IANA timezone is provided #572

Closed
1 task done
anton-patrushev opened this issue Aug 13, 2021 · 10 comments
Labels
bug Something isn't working

Comments

@anton-patrushev
Copy link

Bug Description

Intl.DateTimeFormat API for Android is broken. Please see Steps To Reproduce section to understand the problem.

  • I have run gradle clean and confirmed this bug does not occur with JSC

Hermes version: 0.8.1
React Native version (if any): 0.65.0-rc.4
OS version (if any): macOS BigSur 11.5.1 (Intel)
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): x86

Steps To Reproduce

  1. call Intl.DateTimeFormat with valid IANA timeZone

code example:

const date = new Date('2021-08-13T14:00:00Z');

console.log(
  Intl.DateTimeFormat(undefined, {
    timeZone: 'America/New_York',
    month: 'numeric',
    day: 'numeric',
    hour: 'numeric',
    minute: 'numeric',
  }).format(date),
);

Actual Behavior

Throws an RangeError: com.facebook.hermes.intl.JSRangeErrorException: Invalid timezone name!, js engine: hermes

The Expected Behavior

Should not throw any errors and print to console "8/13, 10:00 AM"

@anton-patrushev anton-patrushev added the bug Something isn't working label Aug 13, 2021
@anton-patrushev
Copy link
Author

Please, pay attention to this PR. I have investigated the source of the issue and tried to provide fix for this bug.

@anton-patrushev
Copy link
Author

Any updates here?

@bviebahn
Copy link

bviebahn commented Sep 9, 2021

Would be great if this could be fixed.

@wojciechkrol
Copy link

Any update with this issue?

@chiubaka
Copy link

Similarly encountering this. Am also using Luxon like it seems like a few other on this thread may be.

Of note, I can use @formatjs polyfills to get around the error, but for whatever reason the @formatjs polyfills cause intolerably slow performance on Android. The app becomes virtually unusable.

@Huxpro This is, unfortunately, a huge (but I think the last) blocker to my migrating to Hermes, as you had suggested here when you added the "show source" directive: mrousavy/react-native-vision-camera#292.

@andreialecu
Copy link

Of note, I can use @formatjs polyfills to get around the error, but for whatever reason the @formatjs polyfills cause intolerably slow performance on Android. The app becomes virtually unusable.

Some information about this here: andreialecu/formatjs-datetimeformat-perf#1

There's a patch at the bottom of the thread which helps quite a lot.

However, now that the linked PR has been merged, I'm hoping to be able to get rid of the formatjs polyfills entirely myself.

@vladyslavNiemtsev
Copy link

vladyslavNiemtsev commented Feb 10, 2022

Hi, guys! Thanks for your updates!

Could you please confirm that this issue is resolved with latest Hermes updates?

@andreialecu
Copy link

This is indeed resolved as of Hermes 0.10.0 and later.

@vladyslavNiemtsev
Copy link

It's a really great news! Thanks guys!

Could we close the issue?

@anton-patrushev
Copy link
Author

It was fixed in scope this PR.
So now Android Hermes starting from the 0.10.0 version should support Intl API correctly.
So I believe as an author of this issue I should close it in that case.

@vladyslavNiemtsev FYI

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

6 participants