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

[Bugfix] Fix date-handling bug when today's date is later than the target month #4614

Merged
merged 4 commits into from
Jan 31, 2024

Conversation

marc-hughes
Copy link
Contributor

@marc-hughes marc-hughes commented Jan 30, 2024

If today's date has a date-part that's bigger than the number of days in the target month, you could not set the schedule to that date because of the way the Date object validates dates.

Explanation of bug:

const d = new Date(); // ex: Date is 1/30/2024
d.setFullYear(2025) // Date is now 1/30/2025
d.setMonth(2); // Date tries to be 2/30/2025, which doesn't exist, and rolls over to 3/1/2025
d.setDate(15); // Date is now 3/15/2025 instead of 2/15/2025 as expected

@darrensiegel darrensiegel merged commit ac74ca6 into hotfix-v0.26.3 Jan 31, 2024
5 checks passed
@darrensiegel darrensiegel deleted the bug/sched-date-handling branch January 31, 2024 12:45
@tzs
Copy link

tzs commented Feb 1, 2024

Possible dumb question since I have had very little occasion to use the Date class and so am probably missing something obvious, but it looks like all these places are creating a new Date object and initializing it to the same date/time as an existing date object.

Couldn't they all be replaced by using the form of the Date constructor that takes an existing date object? E.g., targetStartDate = new Date(startDate)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants