New issue
Advanced search Search tips

Issue 897083 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug


Previous locations:
v8:8289


Sign in to add a comment

Incorrect date returned when initializing date with string

Reported by speer.em...@gmail.com, Oct 10

Issue description

Version: 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`.

 
There are a couple of ways I can think of off the top of my head to solve this issue.

1) Update the `new Date()` call to match up with the other JS engines which would be invalid date.
2) Use the first Month found in the string in this case `Sep` rather then `Jun`. This could cause parsing issues similar to this one.
3) Pick the more precise of the dates. This has the downside of being slower
4) Leave it the way it is.
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)"

Project: chromium
Moved issue v8:8289 to now be issue chromium:897083.
Components: Blink>JavaScript>Internationalization
Labels: Pri-2
Status: Available (was: Untriaged)
Cc: jkummerow@chromium.org
Jakob is this a dupe?
#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.
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