Hermes: Date parse issue

Created on 17 Apr 2020  路  4Comments  路  Source: facebook/hermes

hermes

(new Date("Friday, 17 Apr 2020 07:10:00 +0800")).valueOf();
NaN

chrome / safari / firefox

(new Date("Friday, 17 Apr 2020 07:10:00 +0800")).valueOf();
1587078600000

enhancement

Most helpful comment

It seems like many engines simply ignore any words up to the first space before the date starts, meaning that the "day of the week"can be any string and does not have to actually be a valid day of the week.

We'll look into adding support for that behavior.

Until we do, you can work around this by cutting the first word out of the string before passing it to Date.

All 4 comments

Technically the spec doesn鈥檛 mandate this; however, anything the majority of browsers do is defacto web reality (regardless of which edition one is targeting), so any engine would be wasting effort not to match it.

It seems like many engines simply ignore any words up to the first space before the date starts, meaning that the "day of the week"can be any string and does not have to actually be a valid day of the week.

We'll look into adding support for that behavior.

Until we do, you can work around this by cutting the first word out of the string before passing it to Date.

This particular pattern was added in 013566a05d8dc7a38e7628a6923173896e7edeb8 (thanks @Huxpro).

It will be available in the next release of Hermes.

Please to comment in https://github.com/facebook/hermes/issues/243 if this should be included in the next patch release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gregoirevda picture Gregoirevda  路  3Comments

benkane picture benkane  路  5Comments

akrger picture akrger  路  6Comments

tsengvn picture tsengvn  路  4Comments

swabbass picture swabbass  路  3Comments