diff --git a/src/impl/regexParser.js b/src/impl/regexParser.js index ab095864d..6710d64ea 100644 --- a/src/impl/regexParser.js +++ b/src/impl/regexParser.js @@ -67,11 +67,11 @@ function simpleParse(...keys) { } // ISO and SQL parsing -const offsetRegex = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/; +const offsetRegex = /(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/; const isoExtendedZone = `(?:${offsetRegex.source}?(?:\\[(${ianaRegex.source})\\])?)?`; const isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/; const isoTimeRegex = RegExp(`${isoTimeBaseRegex.source}${isoExtendedZone}`); -const isoTimeExtensionRegex = RegExp(`(?:T${isoTimeRegex.source})?`); +const isoTimeExtensionRegex = RegExp(`(?:[Tt]${isoTimeRegex.source})?`); const isoYmdRegex = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/; const isoWeekRegex = /(\d{4})-?W(\d\d)(?:-?(\d))?/; const isoOrdinalRegex = /(\d{4})-?(\d{3})/; diff --git a/test/datetime/regexParse.test.js b/test/datetime/regexParse.test.js index db84b968f..50d36b709 100644 --- a/test/datetime/regexParse.test.js +++ b/test/datetime/regexParse.test.js @@ -114,6 +114,18 @@ test("DateTime.fromISO() can optionally specify a zone", () => { const isSame = (s, expected) => expect(DateTime.fromISO(s).toObject()).toEqual(expected); +test("DateTime.fromISO() accepts both capital T and lowercase t", () => { + // #1610 + let dt = DateTime.fromISO("2016-05-25T09:08:34.123+06:00"); + isSame("2016-05-25t09:08:34.123+06:00", dt.toObject()); +}); + +test("DateTime.fromISO() accepts both capital Z and lowercase z", () => { + // #1610 + let dt = DateTime.fromISO("2016-05-25T09:08:34.123Z"); + isSame("2016-05-25T09:08:34.123z", dt.toObject()); +}); + test("DateTime.fromISO() accepts just the year", () => { isSame("2016", { year: 2016,