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(Rounding): apply rounding changes to result before applying unit #2890

Conversation

Sjoertjuh
Copy link
Contributor

I was having a problem that looked a bit like #2268.

When rounding down to quarters, the month overflows when a date is after a possible date of the rounded month. This PR causes the changes to be applied before the main unit is changed, so the day is set before the month.

You can see an example in the tests. When rounding down months by a precision of 3, the 31st of may now becomes the 1st of april, instead of the 1st of may.

@kylekatarnls
Copy link
Collaborator

I will run unit tests but I suspect this will break other cases.

@Sjoertjuh
Copy link
Contributor Author

I was thinking the same, but everything still works as expected. Looking at the code coverage report, the re-run in case of overflow part isn't even needed anymore when doing this, so I'll create a commit to remove that part.

If you have any idea on how to better test this let me know.

@kylekatarnls
Copy link
Collaborator

🤔 This should be fine, the code was changed to fix #2268 and a unit test ensure this fix didn't regress.

@kylekatarnls kylekatarnls added this to the 2.72.0 milestone Nov 28, 2023
@kylekatarnls kylekatarnls self-requested a review November 28, 2023 08:47
Copy link
Collaborator

@kylekatarnls kylekatarnls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made few more tests locally and checked 3.x branch. All good.

@kylekatarnls kylekatarnls merged commit a6885fc into briannesbitt:master Nov 28, 2023
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants