Bug 241103 - Date() Constructor not working when using '/' in the Date
Summary: Date() Constructor not working when using '/' in the Date
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari 15
Hardware: All Unspecified
: P2 Normal
Assignee: Nobody
Keywords: InRadar
Depends on:
Reported: 2022-05-30 11:03 PDT by Luis Aguilera
Modified: 2022-06-06 11:04 PDT (History)
4 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
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