Bug 238626 - [JSC] Support non-spec-required date+time input, white-space delimited time (`YYYY-MM-DD HH:mm:ss`) as an extension
Summary: [JSC] Support non-spec-required date+time input, white-space delimited time (...
Status: RESOLVED DUPLICATE of bug 235468
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari 15
Hardware: iPhone / iPad iOS 15
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-31 12:29 PDT by strarsis
Modified: 2022-04-06 03:23 PDT (History)
3 users (show)

See Also:


Attachments
Live demonstration of the issue (32 bytes, text/plain)
2022-03-31 12:31 PDT, strarsis
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description strarsis 2022-03-31 12:29:21 PDT
On `iOS`/`iPad` Safari browser engine the JavaScript `Date` fails to parse `ISO 8601` date+time inputs where the date and time are delimited by a white-space instead of the `T` character (e.g. `2022-03-22 17:51:57`): 
The `Date` constructor fails with `Invalid date format`.

The usage of a white-space as delimiter between date and time isn't specified by ISO 8601, but is allowed by the RFC that is mostly used on the web.
Most Browsers and JavaScript libraries support and output `ISO 8601` formatted dates with date+time delimited by a white-space (`Chrome` (`Blink`/`Chromium`); `Firefox` (`Gecko`); `FeathersJS`; ...).

Code demonstration: `new Date('2022-03-22 17:51:57')`
Live demonstration: https://playcode.io/879708/
Comment 1 strarsis 2022-03-31 12:31:04 PDT
Created attachment 456271 [details]
Live demonstration of the issue
Comment 2 Yusuke Suzuki 2022-04-06 01:34:02 PDT
(In reply to strarsis from comment #0)
> On `iOS`/`iPad` Safari browser engine the JavaScript `Date` fails to parse
> `ISO 8601` date+time inputs where the date and time are delimited by a
> white-space instead of the `T` character (e.g. `2022-03-22 17:51:57`): 
> The `Date` constructor fails with `Invalid date format`.
> 
> The usage of a white-space as delimiter between date and time isn't
> specified by ISO 8601, but is allowed by the RFC that is mostly used on the
> web.

Note that ECMAScript spec is "date-times based upon a simplification of the ISO 8601"[1], not a ISO 8601 or RFC. So using space here is implementation-dependent behavior (spec only accepts "T" case.)

But it can be a good extension.

[1]: https://tc39.es/ecma262/#sec-date-time-string-format
Comment 3 Yusuke Suzuki 2022-04-06 03:23:40 PDT
Ah, I extended it in bug 235468.

*** This bug has been marked as a duplicate of bug 235468 ***