moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.31k stars 729 forks source link

DateTime.fromISO does not work with lowercase 't' #1610

Open toymachiner62 opened 6 months ago

toymachiner62 commented 6 months ago

Describe the bug

When a date has a lowercase 't' between the date and time instead of uppercase 'T', Luxon's DateTime.fromISO() does not parse correctly while the built in javascript Date.parse() does.

DateTime.fromISO('2020-01-01t00:00:00-0300') //  DateTime { Invalid, reason: unparsable }
DateTime.fromISO('2020-01-01T00:00:00-0300') //  DateTime { ts: 2019-12-31T21:00:00.000-06:00, zone: America/Chicago, locale: en-US }
Date.parse('2022-01-01t00:00:00.000Z') // 1640995200000
Date.parse('2022-01-01T00:00:00.000Z') // 1640995200000

Similarly to https://github.com/moment/luxon/issues/1609, the RFC 3339 spec states:

NOTE: Per [[ABNF](https://www.rfc-editor.org/rfc/rfc3339#ref-ABNF)] and ISO8601, the "T" and "Z" characters in this
      syntax may alternatively be lower case "t" or "z" respectively.

To Reproduce Please share a minimal code example that triggers the problem:

Actual vs Expected behavior A lowercase 't' should be parsable.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

toymachiner62 commented 6 months ago

lowercase z should also be supported