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] Calculate daysInMonth without Date(), fixes #3358 #3875
Conversation
I think this works (and if it does, it's very nice) but can we explicitly test the overflow/underflow case that Matt describes in the issue? |
I'm not sure if this actually matters for any of the ways we actually use this internal function, but it's worth noting: By removing Date's overflow behavior when months is < 0 or >= 12, I'm pretty sure you are changing the previous behavior of this function. To be clear, I don't mind the new behavior if the change doesn't break anything, it's just that we should double-check that. |
^ It took me awhile to figure out what was going on here, but this is brilliant. |
Ok, I added some tests detailing the overflow behavior. |
if (modMonth === month) { | ||
return month === 1 ? (isLeapYear(year) ? 29 : 28) : (31 - month % 7 % 2); | ||
} | ||
return daysInMonth(year + (month - modMonth) / 12, modMonth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we please update year if we have a modMonth and not use recursion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it in 475d4c1
Merged in f5953bd |
[bugfix] Calculate daysInMonth without Date(), fixes #3358
fixes #3358