moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.05k stars 728 forks source link

Info.weekdays returning null for different locale(de, ro) on iOS(simulator and real device) #1556

Closed BocanceaIonut closed 6 months ago

BocanceaIonut commented 6 months ago

Describe the bug Info.weekdays returns a list of 7 null elements.

To Reproduce

import { Info } from 'luxon';
const weekdays = Info.weekdays('long', { locale: 'ro' });
console.log('---------------weekdays --------------', weekdays);

OR

import { Info } from 'luxon';
const weekdays = Info.weekdays('long', { locale: 'de' });
console.log('---------------weekdays --------------', weekdays);

Actual vs Expected behavior Expected ["luni", "marți", "miercuri", "joi", "vineri", "sâmbătă", "duminică"] OR ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"]

Actual [null, null, null, null, null, null, null]

Desktop (please complete the following information):

Additional context I installed the following polyfill:

"@formatjs/intl-datetimeformat": "^6.12.0",
"@formatjs/intl-locale": "^3.4.3",

and imported it in index.js like this

import '@formatjs/intl-datetimeformat/locale-data/de';
import '@formatjs/intl-datetimeformat/locale-data/ro';

and it's still not working.

diesieben07 commented 6 months ago

Please post the output of the following snippet in your runtime:

const intl = new Intl.DateTimeFormat('de', { weekday: 'long' });
console.log(intl.formatToParts(new Date()));

It should output something like this:

[
  { "weekday": "Donnerstag" }
]
BocanceaIonut commented 6 months ago

The output of

const intl = new Intl.DateTimeFormat('de', { weekday: 'long' });
console.log('----------', intl.formatToParts(new Date()));

is ---------- [{"type": "literal", "value": "Donnerstag"}]

diesieben07 commented 6 months ago

That suggests you are using Hermes, which unfortunately has an incomplete and not spec-compliant implementation of Intl.DateTimeFormat. The output you posted is not correct, as you can see the value is marked as a literal, not a weekday. I suggest you report this bug to Hermes. See also https://github.com/moment/luxon/issues/1500.