facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.73k stars 625 forks source link

Intl.DateTimeFormat returns incorrect values on real iOS devices #1172

Open jonassvalin opened 11 months ago

jonassvalin commented 11 months ago

Bug Description

Greetings 👋 We use Luxon in our react-native project for date management. When parsing dates and attempting to output the monthShort or weekdayShort components whilst using a real iOS device, we get null values back.

There is an open issue in Luxon stating that this is an implementation issue in Hermes as it works correctly for other JavaScript engines: https://github.com/moment/luxon/issues/1500

Hermes version: bundled with react-native React Native version: 0.72.5 Platform: iOS OS version: 16.6.1

Steps To Reproduce

Direct Hermes example:

https://github.com/moment/luxon/issues/1500#issuecomment-1709612387

Luxon example:

import { DateTime } from 'luxon'
...

  console.log(DateTime.now().month) // -> 10
  console.log(DateTime.now().monthShort) // -> null, but expected Oct or equivalent
neildhar commented 11 months ago

Thank you for reporting this. Unfortunately, this is a known problem in our implementation of formatToParts on iOS. Hermes currently implements Intl on top of the APIs exposed by the platform, but these APIs are not sufficiently broad on iOS to create a correct implementation of formatToParts.

We have disabled DateTimeFormat.prototype.formatToParts on iOS for now, because of the known correctness problems. Instead, we are working on implementing a version of Intl on top of ICU which will allow us to provide a much broader and more correct Intl implementation at the expense of the added binary size cost of ICU.

jonassvalin commented 11 months ago

@neildhar Thank you for the update. Is there any rough idea of when the new implementation will be prioritised?

tmikov commented 9 months ago

FYI, we haven't forgotten this (and other issues). Here is an update on our latest plans: https://github.com/facebook/hermes/discussions/1211

IanCStewart commented 2 weeks ago

Actively bumped into this issue today. Are there any updates regarding this bug?