Closed
Bug 1468499
Opened 7 years ago
Closed 1 year ago
Date has an issue with the format returning the correct actual date.
Categories
(Core :: JavaScript: Standard Library, defect, P3)
Tracking
()
RESOLVED
DUPLICATE
of bug 1655947
People
(Reporter: azel, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
124.70 KB,
image/jpeg
|
Details |
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36
Steps to reproduce:
Your Date function seems broken. Try
let date = new Date("JUN 13, 18");
console.log(date);
Then try
let date = new Date("JUN 20, 18");
console.log(date);
It seems to take the largest number as the year, regardless.
Actual results:
First returns:
Wed Jun 13 2018 00:00:00 GMT-0400 (EDT)
second returns
Thu Jun 18 2020 00:00:00 GMT-0400 (EDT)
Expected results:
first should return:
Wed Jun 13 2018 00:00:00 GMT-0400 (EDT)
second should return:
Wed Jun 20 2018 00:00:00 GMT-0400 (EDT)
Should note, mine shows linux right now so this is version 54, but I tested it on 60 as well on Windows. So seems to have been an issue for awhile
Comment 2•7 years ago
|
||
Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0 (20180618100844)
I have tested this report on Ubuntu 18.04 using latest Nightly and Firefox release build and I was able to reproduce it.
When execute the below function:
let date = new Date("JUN 20, 18");
console.log(date);
I got the following result:
Date 2020-06-18T07:00:00.000Z
As mentioned in the report the function seems to take the largest number as the year.
This is not reproducible on Windows 10 x64 for me.
I think the correct component would be DevTools::Console. Please change if this is not the right component.
Updated•7 years ago
|
Status: UNCONFIRMED → NEW
Component: Untriaged → Console
Ever confirmed: true
Product: Firefox → DevTools
Comment 3•7 years ago
|
||
Comment 4•7 years ago
|
||
I think it's more an engine issue.
For what it's worth, Chrome parses the string as June 20.
Also, MDN warns about using a string for the Date constructor [1] :
> Note: parsing of date strings with the Date constructor (and Date.parse, they are equivalent) is strongly discouraged due to browser differences and inconsistencies. Support for RFC 2822 format strings is by convention only. Support for ISO 8601 formats differs in that date-only strings (e.g. "1970-01-01") are treated as UTC, not local.
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
Component: Console → JavaScript Engine
Product: DevTools → Core
Updated•5 years ago
|
Component: JavaScript Engine → JavaScript: Standard Library
Updated•2 years ago
|
Severity: normal → S3
Comment 5•1 year ago
|
||
This was fixed in bug 1655947. :)
You need to log in
before you can comment on or make changes to this bug.
Description
•