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

Error when initializing Date objects with non-ISO strings #68

Open
pcnova opened this issue Jan 7, 2024 · 1 comment
Open

Error when initializing Date objects with non-ISO strings #68

pcnova opened this issue Jan 7, 2024 · 1 comment

Comments

@pcnova
Copy link

pcnova commented Jan 7, 2024

Trying the following in a unit test...

timezone-mock.register('US/Pacific');
const nonIso = new Date('Fri, 05 Jan 2024 23:00:00');

...results in the following error:

Unhandled date format passed to MockDate constructor: Fri, 05 Jan 2024 23:00:00
@Jimbly
Copy link
Owner

Jimbly commented Jan 7, 2024

That's the kind of bug this library is useful to catch =). That is a non-standard date format that may parse differently based on timezone and browser (and possibly even locale, since there's English words in there?). There are a number of non-ISO formats accepted by this library, but only those that have defined behavior in the JS spec.

If there's a compelling reason to support that format, and it can be shown that it's treated the same in all browsers in all locales, and all Node versions, then maybe it's fine though, and a PR to handle it would be accepted.

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