Comment on Fix date-handling bug when today’s date is later than the target monthparentComments−Izkata2ybut with extra logic to ensure that the Month component wrapped aroundExtra 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)−Pxtl2yDepends on the language/library. C#'s DateTime will throw ArgumentOutOfRangeException.
Comments
Extra unnecessary logic. The functionality that causes this bug is so you don't need to handle wraparound yourself:
(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:
Depends on the language/library. C#'s DateTime will throw ArgumentOutOfRangeException.