Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(timepicker): fix date overflow on short months #6480

Conversation

a-mcc
Copy link

@a-mcc a-mcc commented Jul 7, 2022

Change year, month, date setting on time change to be atomic, preventing overflows for short months.
When the time is decremented before midnight such that the date would go back a day there is code to reset the year, month and day, in that order. this causes an issue with shorter months, for example February or April, when on the 1st of these months and the date goes back a day, calling date.setMonth(monthIndex) causes an overflow to the next month.
For example, February 1st 00:00:00 -> January 31st 23:00:00
Upon calling date.setMonth(1) we are essentially setting the date to February 31st which rolls over a few into March. date.setDate(1) is then called which results in the Date object representing March 1st, instead of February 1st.
The fix is a simple one, date.setFullYear accepts arguments for year, month and day, allowing these to be set atomically and prevents this overflow issue.

Closes #5766

a-mcc and others added 2 commits July 7, 2022 13:43
change year, month, date setting on time change to be atomic, preventing overflows for short months

Closes 5766
@lexasq lexasq changed the base branch from development to 18-1-3-release-candidate October 21, 2024 14:53
@lexasq lexasq deleted the branch valor-software:18-1-3-release-candidate October 28, 2024 13:56
@lexasq lexasq closed this Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spinning the timepicker down below zero on April 1st moves the date to May 1st
2 participants