Skip to content

"toAbsoluteLocaleDate" test doesn't pass when system locale is not en-US #33937

Closed
@YaFou

Description

@YaFou

Description

When I run the tests from source using make test-frontend, the toAbsoluteLocaleDate doesn't pass.

 FAIL  web_src/js/webcomponents/absolute-date.test.ts > toAbsoluteLocaleDate
AssertionError: expected '14/03/2024 20:00:00' to deeply equal '3/14/2024, 8:00:00 PM'

Expected: "3/14/2024, 8:00:00 PM"
Received: "14/03/2024 20:00:00"

I succeeded to fix the bug by setting the locale in the test:

@@ -20,7 +20,7 @@ test('toAbsoluteLocaleDate', () => {
   // test different timezone
   const oldTZ = process.env.TZ;
   process.env.TZ = 'America/New_York';
-  expect(new Date('2024-03-15').toLocaleString()).toEqual('3/14/2024, 8:00:00 PM');
-  expect(toAbsoluteLocaleDate('2024-03-15')).toEqual('3/15/2024, 12:00:00 AM');
+  expect(new Date('2024-03-15').toLocaleString('en-US')).toEqual('3/14/2024, 8:00:00 PM');
+  expect(toAbsoluteLocaleDate('2024-03-15', 'en-US')).toEqual('3/15/2024, 12:00:00 AM');
   process.env.TZ = oldTZ;
 });

I can open a pull request if you want.

Gitea Version

39fc2e7

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

Arch Linux

How are you running Gitea?

I installed Gitea from source using the documentation. I'm using Arch Linux with the fr_FR locale.

Database

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions