Join GitHub today
Make sure TimeIntervalRounding is monotonic for increasing dates #19020
Currently there are cases when using TimeIntervalRounding#round() that if
Here is an example for the "CET" time zone with a 45 minute rounding interval. The dates to be rounded are on the left (with utc time stamp), the rounded values on the right. The error case is marked:
We should correct this by detecting that we are crossing a transition when rounding, and in that case pick the largest valid rounded value before the transition.
This change adds this correction logic to the rounding function and adds this invariant to the randomized TimeIntervalRounding tests. Also adding the example test case from above (with corrected behaviour) for illustrative purposes.