3 ms·
> but with extra logic to ensure that the Month component wrapped around Extra unnecessary logic. The functionality that causes this bug is so you don't need
by Izkata 3y ago
> but with extra logic to ensure that the Month component wrapped around
Extra unnecessary logic. The functionality that causes this bug is so you don't need to handle wraparound yourself:
>> new Date(2023, 12, 1)
Date Mon Jan 01 2024 00:00:00 GMT-0600 (Central Standard Time)
(Note months are 0-indexed so 12 is one past the last month of the year)
It works with negative numbers too, to wrap backwards:
>> new Date(2024, -1, 1)
Date Thu Dec 01 2023 00:00:00 GMT-0600 (Central Standard Time)
- Pxtl 3y agoDepends on the language/library. C#'s DateTime will throw ArgumentOutOfRangeException.