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

MockDate constructor doesn't support "MM/DD/YYYY, hh:ii:ss (AM|PM)" format #72

Open
inxmail-de-cln opened this issue Jan 7, 2025 · 1 comment

Comments

@inxmail-de-cln
Copy link

When creating an instance of an MockDate with i.e. "10/24/2023, 1:59:00 AM" it throws an error: AssertionError: Unhandled date format passed to MockDate constructor: 10/24/2023, 1:59:00 AM.

It occurs while running tests using the current version of the Mantine-Framework and the error is been thrown at this line: https://github.com/mantinedev/mantine/blob/master/packages/@mantine/dates/src/components/DateTimePicker/DateTimePicker.tsx#L157

I guess the origin of this string is toLocaleString.

When using this pattern in the actual Date-constructor in Chrome, Firefox or Node.js it doesn't throw an error.

console.log(new Date("10/24/2023, 1:59:00 AM"));
//2023-10-23T23:59:00.000Z
@Jimbly
Copy link
Owner

Jimbly commented Jan 7, 2025

Looks probably the same as #68 - that's generally the kind of bug this library is good at helping catch - that looks like a format which will parse differently depending on the browser/Node version and the locale of the computer running the test (in many non-US/English locales, a browser is going to try to parse it as DD/MM/YYYY, I think?).

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

No branches or pull requests

2 participants