Closed FrancoTanzarella closed 11 months ago
This seems to be a problem with the implementation of Intl.DateTimeFormat#formatToParts
. Take this code:
const dtf = new Intl.DateTimeFormat('en-GB', {month: 'long'});
console.log(dtf.formatToParts(new Date()));
V8 (i.e. NodeJS, Chrome and related browsers) and Firefox report the following:
[
{ "type": "month", "value": "August" }
]
In sandbox environment you shared, this code produces the following (incorrect, note the type
key) result instead:
[
{ "type": "literal", "value": "August" }
]
I currently do not have the ability to test this on an actual iOS device (or Safari on macOS). But it seems you'll have to open a bug report in whichever environment causes this wrong result.
Safari 16.6 returns [{type: "month", value: "August"}]
Thank you for testing, it sounds like this is yet another bug with Hermes.
Thanks for the feedback. I can get around this using globalize for the month and day names for now.
You could also use this polyfill.
Describe the bug This happens on iOS only.
Info.months('long', {locale: 'en-GB'})
returns an array filled withnull
but replacingen-GB
with justen
returns the month names. I can't get around this by stripping of-GB
since we support other languages likees-CA, es-ES
etc.To Reproduce snack:
Actual vs Expected behavior expect the
en-GB
and other locales to work.Desktop (please complete the following information):
Additional context Add any other context about the problem here.