Incorrect date returned when initializing date with string
Reported by
speer.em...@gmail.com,
Oct 10
|
|||
Issue descriptionVersion: cbda8ebc01bde1b7fec5d52a6d49aea19151ef4a OS: Linux 4.15.0-34-generic x86_64 Architecture: x64 What steps will reproduce the problem? 1. In any system that is using V8 provide the code below. `console.log(new Date("Fri Sep 14 2018 12:44:48 GMT+0200 (Central European Summer Time) junk").toString())` Online: https://codepen.io/anon/pen/VGBByJ?editors=1112 What is the expected output? Fri Sep 14 2018 03:44:48 GMT-0700 (Pacific Daylight Time)" What do you see instead? Thu Jun 14 2018 03:44:48 GMT-0700 (Pacific Daylight Time)" Please use labels and text to provide additional information. This issue is linked to https://bugs.chromium.org/p/v8/issues/detail?id=8187&desc=2 in which all other JS engines treat the above string as an invalid date. The change from Sep to Jun appears to be caused by the J in `junk`.
,
Oct 15
Results from different browsers:
Test code:
console.log(new Date("Fri Sep 14 2018 12:44:48 GMT+0200 (Central European Summer Time) junk").toString());
Firefox:
"Invalid Date"
Edge:
"Invalid Date"
IE:
"Invalid Date"
Safari:
"Invalid Date"
Chrome:
"Thu Jun 14 2018 03:44:48 GMT-0700 (Pacific Daylight Time)"
,
Oct 19
,
Oct 19
,
Oct 19
Jakob is this a dupe?
,
Oct 19
#5: Depends on how you look at it: - v8:8187 summarizes as: "Sep 14 junk" should be rejected as "Invalid Date". - this here summarizes as: If Chrome chooses not to reject "Sep 14 junk", then it should be parsed as "September", not as "June". Which means if we close v8:8187 as WAI, then this issue deserves its own consideration. If we decide to fix v8:8187 as suggested, then we can either close this one as Invalid/Obsolete or dupe it back into v8:8187. Personally I think rejecting such strings sounds reasonable (as v8:8187 suggested), but I can't judge the compatibility risk.
,
Oct 19
I'm personally of the mind that because this is an "Invalid Date" in all engines other then V8 it should be changed for cross browser compatibility. |
|||
►
Sign in to add a comment |
|||
Comment 1 by speer.em...@gmail.com
, Oct 10