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

new Date() not throwing an Invalid Date error #1148

Open
1 task done
acerslee opened this issue Oct 6, 2023 · 1 comment
Open
1 task done

new Date() not throwing an Invalid Date error #1148

acerslee opened this issue Oct 6, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@acerslee
Copy link

acerslee commented Oct 6, 2023

Bug Description

When calling new Date() with a stringified date that contains '00', instead of throwing me an error it converts it to a previous date.
Screenshot 2023-10-06 at 1 48 37 PM

  • I have run gradle clean and confirmed this bug does not occur with JSC

Hermes version: 0.12
React Native version (if any): 0.71.13
OS version (if any): 16.4
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): x86_64

Steps To Reproduce

  1. Call new Date() with a date that contains a '00' in the string. Ex new Date('1999-00-00')

code example:

The Expected Behavior

Should throw an 'Invalid Date' error

Actual Behavior

Returns 1998-11-30T00:00:00.000Z (as shown in the screenshot)

@acerslee acerslee added the bug Something isn't working label Oct 6, 2023
@neildhar
Copy link
Contributor

neildhar commented Oct 6, 2023

Thank you for reporting this, the behaviour here is interesting, especially as we look at going in the other direction. For instance, both Hermes and V8 will accept new Date('1999-02-31'), whereas JSC and SM will not.

It would be relatively simple to add the kind of basic validation V8 seems to be doing (and the spec seems to require it), but matching JSC and SM will likely be more involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants