moment / luxon

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

throwOnInvalid does not throw for invalid year #1449

Closed kryops closed 9 months ago

kryops commented 1 year ago

Describe the bug When setting Settings.throwOnInvalid, Luxon does not seem to throw an error if the year is too large (both positive or negative), even though dateTime.isValid will return false.

To Reproduce

luxon.Settings.throwOnInvalid = true;

const dateTime = luxon.DateTime.fromObject({ year: 1000000 });
console.log(dateTime.isValid, dateTime.invalidReason);

Actual vs Expected behavior

Expected: An error is thrown

Actual: false invalid input is logged to the console

Desktop:

Thanks for looking into it!