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

Feature/month addition #875

Merged
merged 13 commits into from
Apr 4, 2024
Merged

Conversation

grasdk
Copy link
Contributor

@grasdk grasdk commented Apr 4, 2024

What does 1 month back mean, when it's 31st of march 2020 (which was a leap year)?

Does it mean 31st of february, which doesn't exist, so 31st of february becomes 29th of february + 2 days, i.e. 2nd of march?

  • That's how Javascript and therefore Typescript does it, when you subtract one from month, using the Date.setMonth function.

I think that when you subtract a month, you HAVE to end up in the previous month. And the consequence is that 31st of March 2020 minus 1 month becomes 29th of february (and even the 28th on non-leap years).

  • 30th and 31st of march minus 1 month becomes 29th of february on leap years
  • 29th, 30th and 31st of march minus 1 month becomes 28th of february on non-leap years
  • 31st of may, july, october and december minus 1 month becomes 30th of april, june, september and november respectively.

This PR alters the behavior or x months subtration in this manner. :)

@bpatrik
Copy link
Owner

bpatrik commented Apr 4, 2024

aggh that is rough.
Thanks for finding and fixing it!

@bpatrik bpatrik merged commit bf77662 into bpatrik:master Apr 4, 2024
4 of 7 checks passed
@grasdk grasdk deleted the feature/month-addition branch April 4, 2024 21:35
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.

2 participants