NEW241103
Date() Constructor not working when using '/' in the Date
https://bugs.webkit.org/show_bug.cgi?id=241103
Summary Date() Constructor not working when using '/' in the Date
Luis Aguilera
Reported 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.
Attachments
Alexey Proskuryakov
Comment 1 2022-05-30 19:05:01 PDT
Could you please clarify why you expect this format to work? Does it work in other browsers?
Luis Aguilera
Comment 2 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.
nanomiratus
Comment 3 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.
Radar WebKit Bug Importer
Comment 4 2022-06-06 11:04:12 PDT
Note You need to log in before you can comment on or make changes to this bug.