Bug 241103

Summary: Date() Constructor not working when using '/' in the Date
Product: WebKit Reporter: Luis Aguilera <luis.aguilera>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: nanomiratus, saam, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: All   
OS: Unspecified   

Description Luis Aguilera 2022-05-30 11:03:41 PDT
When using the constructor Date() in Javascript, with a date that has backslashes on it, the Date the constructor returns "Invalid Date".

For example:

new Date("17/AUG/1996")

Returns "Invalid Date"

new Date("17-AUG-1996")

Returns a valid date.
Comment 1 Alexey Proskuryakov 2022-05-30 19:05:01 PDT
Could you please clarify why you expect this format to work? Does it work in other browsers?
Comment 2 Luis Aguilera 2022-05-31 06:42:55 PDT
Hello Alexey, the same format works in Google Chrome, Firefox and Edge when accessed from a Windows computer.
Comment 3 nanomiratus 2022-06-03 06:18:50 PDT
To quote MDN:
"The ECMAScript specification states: If the String does not conform to the standard format the function may fall back to any implementation–specific heuristics or implementation–specific parsing algorithm. Unrecognizable strings or dates containing illegal element values in ISO formatted strings shall cause Date.parse() to return NaN."

This means that WebKit could theoretically support these date formats. In my opinion though, it shouldn't. Especially with Temporal getting closer and closer to Stage 4, developers of any browser shouldn't focus on implementing support for niche unofficial date formats for the Date constructor, which is the part in the ECMAScript specification with the most fundamental flaws and design mistakes.

Supporting stuff like "17/AUG/1996" is optional and not a MUST in the spec. Date is old and crappy. Don't do it.
Comment 4 Radar WebKit Bug Importer 2022-06-06 11:04:12 PDT
<rdar://problem/94446483>