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

Hermes Date constructor problem #136

Closed
chufengma opened this issue Oct 17, 2019 · 6 comments
Closed

Hermes Date constructor problem #136

chufengma opened this issue Oct 17, 2019 · 6 comments
Labels
wontfix This will not be worked on

Comments

@chufengma
Copy link

in hermes(0.2.1):

// test.js
let d = new Date("2019/10/16").getTime();
print(d);
----
// run with hermes 0.2.1
>>> hermes-cli-darwin-v0.2.1/hermes test.js
>>> NAN

in Node:

let d = new Date("2019/10/16").getTime();
console.log(d);
----
// run with node
>>> node test.js
>>> 1571155200000
@chufengma
Copy link
Author

chufengma commented Oct 17, 2019

And

// run with hermes 0.2.1
new Date("2019-10-16 00:00:00+0800").getTime()
---
NaN

@ljharb
Copy link

ljharb commented Oct 17, 2019

The spec doesn’t mandate both of those formats; off the top of my head, only safari supports the slashes (I’m not at a computer so i can’t verify rn)

@mhorowitz
Copy link
Contributor

mhorowitz commented Oct 17, 2019

Thanks for the feedback! @ljharb is correct. In order to keep the VM small, we have chosen to parse only the strings the spec requires. If you require parsing other date formats, we suggest using an npm module which implements richer date parsing such as https://www.npmjs.com/package/moment, or you can write your own.

@flyskywhy
Copy link

https://www.npmjs.com/package/dayjs

let d = new Date(dayjs("2019/10/16")).getTime();

@PrimulaX
Copy link

PrimulaX commented Jun 8, 2021

In RN project on Android (Hermes enabled) app keeps crashing on Date.prototype.toDateString()

@mhorowitz
Copy link
Contributor

@PrimulaX please open a new issue using one of the forms at https://github.com/facebook/hermes/issues/new/choose. Include as much logging or repro information as you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

5 participants