NEW 283825
non standard new Date('2024-12-3') yields to Invalid Date
https://bugs.webkit.org/show_bug.cgi?id=283825
Summary non standard new Date('2024-12-3') yields to Invalid Date
Sebastian Schlatow
Reported 2024-11-29 06:10:20 PST
new Date('2024-12-3') yields to: Invalid Date Date.parse('2024-12-3') yields to: NaN Firefox: new Date('2024-12-3') yields to: Date Tue Dec 03 2024 00:00:00 GMT+0100 (Central European Standard Time) Date.parse('2024-12-3') yields to: 1733180400000 Chromium: new Date('2024-12-3') yields to: Tue Dec 03 2024 00:00:00 GMT+0100 (Central European Standard Time) Date.parse('2024-12-3') yields to: 1733180400000
Attachments
Karl Dubost
Comment 1 2024-12-01 19:19:58 PST
> the value produced by this function is implementation-defined when given any String value that does not conform to the Date Time String Format (21.4.1.32) and that could not be produced in that implementation by the toString or toUTCString method. While this leads to an identical result in Firefox and Chrome. Per sec this is an implementation defined format. https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date-time-string-format @Sebastian, did you notice a website breaking because of this?
Karl Dubost
Comment 2 2024-12-01 19:20:56 PST
The valid format per spec is `YYYY-MM-DDTHH:mm:ss.sssZ` or a truncation of it.
Sebastian Schlatow
Comment 3 2024-12-02 07:13:43 PST
> did you notice a website breaking because of this? @Karl yes, our inhouse webapp, but we found a work around ;) But nonetheless it would be great if it were more robust.
Radar WebKit Bug Importer
Comment 4 2024-12-06 06:11:13 PST
Karl Dubost
Comment 5 2024-12-08 17:29:24 PST
Bug 223166 is the bug for the implementation of Temporal. It doesn't fix this specific issue, but it helps figure out the priorities. It would be interesting to dig if there have been more compat issues reported because of this.
Karl Dubost
Comment 7 2024-12-08 17:39:51 PST
ha no, this was for "2024/12/03". The standard parsing with dashese is at https://searchfox.org/wubkat/rev/52d16c972a163b36fe64a99efb66af93c6e2f2b2/Source/WTF/wtf/DateMath.cpp#616-673
Karl Dubost
Comment 8 2024-12-08 17:44:33 PST
which calls parseES5DatePortion(std::span<const LChar>& currentPosition, int& year, long& month, long& day) https://searchfox.org/wubkat/rev/52d16c972a163b36fe64a99efb66af93c6e2f2b2/Source/WTF/wtf/DateMath.cpp#448-490
Note You need to log in before you can comment on or make changes to this bug.