moment / luxon

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

DateTime is not invalid like it should be when using hour 15 with 12-hour time token. #1549

Open Matthematic opened 7 months ago

Matthematic commented 7 months ago

Describe the bug Correct me if I'm wrong, but shouldn't this return an invalid DateTime?

luxon.DateTime.fromFormat('11-08-2023 15:00 AM', 'MM-dd-yyyy hh:mm a').toString()
// '2023-11-08T15:00:00.000-06:00'

To Reproduce Just go to the Luxon docs and paste the example above into the console.

image

Actual vs Expected behavior The date string supplied is using hour 15 with a meridian, and the format string is expecting 12-hour time. Shouldn't luxon notice that hour 15 is out of bounds and return an Invalid object?

Desktop (please complete the following information):

icambron commented 7 months ago

Probably should, yeah.

KengSSK commented 6 months ago

Recommended for beginners.