date-fns
date-fns copied to clipboard
`roundToNearestMinutes` fixes and improvements
Closes #3129
The recent addition of the roundingMethod option (#3091) was not implemented correctly, and some unit tests were not checking for the right behavior. This PR fixes the problems, adds several unit tests, improves the JS docs and adds two additional examples.
I've also internally renamed the getRoundingMethod file and made the function as a default export for consistency to match other functions in the library.
@im28 Would you mind reviewing the PR, especially the unit tests to make sure everything checks out and there are no missing edge cases?
Just pushed an update to cover an edge case with ceil and milliseconds.
Hi, would someone be able to fix these merge conflicts so this can be released? I'm relying on this fix for a development! Thanks :)
@fturmel
It seems like main has become the working branch for pre-released v3 since I opened this, which explains all the conflicts.
@leshakoss @tan75 I'm going to wait for you to chime in before changing anything. If you want to accept the PR, let me know if you want to merge into the v2 branch instead, or if I should get rid of the conflicts against main.
Obviously the fixes in this PR should find their way to both v2 and upcoming v3.
Any updates on this PR?
While this PR hasn't been merged, I'm using this simple custom solution https://stackoverflow.com/a/10789415
Would also appreciate this being merged.
Shipped with https://github.com/date-fns/date-fns/releases/tag/v3.2.0