-
Notifications
You must be signed in to change notification settings - Fork 744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Add 'T' character if needed to ISO-8601 strings #1325
Comments
Related to #990 |
@dasa what was the solution for this? I don't see any relevant commits around the time 990 was closed and no option such as |
I closed #990 since it seemed to be rejected, but here's my own workaround: // ISO 8601 time extension starts with T and then two digits.
// Moment and RFC 3339 also allow the use of a space char instead.
// https://github.com/moment/luxon/issues/990
const re = / (\d\d)/;
let dateTime = DateTime.fromISO(v);
if (dateTime.isValid) {
return dateTime;
} else if (re.test(v)) {
// replace space with a T and try again
v = v.replace(re, "T$1");
dateTime = DateTime.fromISO(v);
if (dateTime.isValid) {
return dateTime;
}
} |
As far as I understand it, the string with a space in it isn't an ISO 8601 string. I don't want to support it because a lot of people rely on Luxon's validations to (mostly) filter out bad ISO strings that other parsers downstream may choke on. Note that |
Like @icambron said, only |
When trying to use
DateTime.fromISO
for an ISO-8601 string that contains a space instead of aT
character (aka, instead of2022-11-14T19:56:20
, a string like2022-11-14 19:56:20
, Luxon should handle this alternative format or should provide an option to allow theT
to be added.The text was updated successfully, but these errors were encountered: