hermes icon indicating copy to clipboard operation
hermes copied to clipboard

iOS `DateTimeFormat` `{ hour: "numeric", minute: "numeric" }` does not use locale setting

Open andreialecu opened this issue 2 years ago • 6 comments

Bug Description

      console.log(
        new Intl.DateTimeFormat('en-US', {
          hour: 'numeric',
          minute: 'numeric',
        }).format(new Date('2021-09-30T18:00:00.000Z')),
      );

The above prints 21:00 (incorrect because of locale) on iOS, but 9:00 PM (correct) on Android.

On iOS, using timeStyle: 'short' correctly prints 9:00 PM but on Android it prints 9/30/2021 as timeStyle is not implemented:

      console.log(
        new Intl.DateTimeFormat('en-US', {
          timeStyle: 'short'
        }).format(new Date('2021-09-30T18:00:00.000Z')),
      );

andreialecu avatar Nov 19 '23 09:11 andreialecu

Related: https://github.com/facebook/hermes/issues/1172#issuecomment-1776156538

andreialecu avatar Nov 19 '23 09:11 andreialecu

Hey @andreialecu, thanks for reporting this. Could you also share which version of Hermes you are using, as well as the iOS/Android version you are testing on?

It would also be helpful to see what the output of resolvedOptions is to see what locale the implementation is actually using.

neildhar avatar Nov 19 '23 19:11 neildhar

I would like to follow up on this issue since @andreialecu is not active.

Hi @neildhar and @tmikov.

Device: Physical Iphone, version 17.5.1 Hermes Version: 0.73.6

I am trying to format time in german like this:

new Intl.DateTimeFormat('de', {
    hour: '2-digit',
    minute: '2-digit',
}).format(date)

Time in german is 24 hour but it is showing it as 12 hour with am/pm.

However I use a time picker and pass it the locale. Using en correctly shows a 12 hour picker while passing de shows a 24 hour picker.

Please let me know if you still need info

itsramiel avatar Aug 07 '24 06:08 itsramiel

@itsramiel Thanks for sharing this, I can repro this and I think I know what the issue is. We'll fix it soon.

neildhar avatar Aug 07 '24 16:08 neildhar