hermes icon indicating copy to clipboard operation
hermes copied to clipboard

Intl.DateTimeFormat returns incorrect values on real iOS devices

Open jonassvalin opened this issue 2 years ago • 4 comments

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

jonassvalin avatar Oct 23 '23 10:10 jonassvalin

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.

neildhar avatar Oct 23 '23 23:10 neildhar

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

jonassvalin avatar Oct 24 '23 07:10 jonassvalin

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

tmikov avatar Dec 08 '23 18:12 tmikov

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

IanCStewart avatar Sep 09 '24 10:09 IanCStewart