Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime tokenParse test ex16 failing on Node 22.2.0 #1675

Open
tonysamperi opened this issue Dec 28, 2024 · 4 comments
Open

DateTime tokenParse test ex16 failing on Node 22.2.0 #1675

tonysamperi opened this issue Dec 28, 2024 · 4 comments

Comments

@tonysamperi
Copy link

Describe the bug
The following test fails, cause there's no match

  const ex16 = DateTime.fromFormatExplain(
    "௦௩-ஏப்ரல்-௨௦௧௯ ௦௪:௦௦:௪௧ பிற்பகல்",
    "dd-MMMM-yyyy hh:mm:ss a",
    {
      locale: "ta",
      numberingSystem: "tamldec",
    }
  );
  expect(ex16.rawMatches).toBeInstanceOf(Array);

To Reproduce
Just run the test "DateTime.fromFormatExplain() parses localized string with numberingSystem correctly" using Node 22.2.0

Actual vs Expected behavior
The test fails with "expected Array, was null"

Desktop (please complete the following information):

  • OS: Ubuntu 24.04.1 (WSL) / Windows 11
  • Browser: terminal
  • Luxon version: 3.5.0
  • Your timezone: "America/New_York" (on Ubuntu) / "Europe/Rome" (on Windows)

Additional context
Nothing to add so far

@diesieben07
Copy link
Collaborator

It appears that Node 22 has changed how it formats the meridiem (AM/PM):

console.log(
  new Date('2019-04-03T12:26:07.000+05:30').toLocaleString('kn', {
    hour: '2-digit', minute: '2-digit', hour12: true,
    numberingSystem: 'knda'
  })
);

In Node 22 this outputs ೦೧:೫೬ AM, in Node 20 it outputs ೦೧:೫೬ ಪೂರ್ವಾಹ್ನ.

I'm going to try and find out more info about whether this is an intentional change on Node's side, if ICU data has changed or what happened here.

@diesieben07
Copy link
Collaborator

This is a change that happened in CLDR, which is where Node (and pretty much everything) get's its locale data.
As you can see in this delta, the day-period locale values were changed from CLDR 45 (which Node 20 uses) to CLDR 46 (which Node 22 uses).

I'll look into making a pull request to make the test pass, but there is not really anything Luxon can do about the value changing.

@icambron
Copy link
Member

icambron commented Dec 28, 2024

@diesieben07 On the one hand, this looks intentional: just ICU translating AM and PM into Kanada. But on the other hand...it also seems incorrect; "ಪೂರ್ವಾಹ್ನ" apparently means PM, and here it should be AM? Also, usages I've found put the meridiem before the time. This maybe a little half-baked from the ICU, and we're sort of caught in the middle.

I suspect if we fix the test, we'll just have to fix it again due to incremental fixes to ICU. Maybe we can just change the language the test uses? Or perhaps we don't need this one at all?

@tonysamperi
Copy link
Author

tonysamperi commented Dec 28, 2024

Hey guys thanks for checking this out.
Maybe a way could be using a 24h for now?

Anyway not a big deal, I just wanted to warn you that when you would switch to 22 you would probably get the error.

Thanks

EDIT

I tested and this works fine. Should allow keeping the test (so at least a basic testing of that locale/numbering) and make it work on every version of Node.
I could open a PR if you need help.

    const ex16 = DateTime.fromFormatExplain(
        "௦௩-ஏப்ரல்-௨௦௧௯ ௦௪:௦௦:௪௧",
        "dd-MMMM-yyyy hh:mm:ss",
        {
            locale: "ta",
            numberingSystem: "tamldec"
        }
    );

  expect(ex16.rawMatches).toBeInstanceOf(Array);
  expect(ex16.matches).toBeInstanceOf(Object);
  expect(keyCount(ex16.matches)).toBe(6); // Was 7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants