moment / luxon

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

Luxon fails to parse ISO 8601 date with 'Z' suffix as UTC #1596

Closed BenjaminHofstetter closed 4 months ago

BenjaminHofstetter commented 4 months ago

Describe the bug When using Luxon's DateTime.fromISO() function with the string '2023-12-04Z', the date is parsed as invalid.

To Reproduce Minimal code example:

const { DateTime } = require('luxon');
const date = DateTime.fromISO('2023-12-04Z');
console.log(date.isValid); // false

Actual vs Expected behavior Expected behavior: The date '2023-12-04Z' should be parsed as a valid date. Actual behavior: Luxon parses '2023-12-04Z' as an invalid date.

Desktop (please complete the following information):

Additional context This issue occurs when attempting to parse ISO 8601 dates with Luxon. The 'Z' suffix indicates that the date is in UTC time, and it should be parsed correctly.

diesieben07 commented 4 months ago

You can only specify an offset if you also specify a time. Just a date plus offset is not valid in ISO 8601.