fix calculate_relative_offset year offset from Feb 29 - #9968
Conversation
…up#9967 Reusing offset_n_months for the year case naturally clamps the day to the last day of the target month, so Feb 29 + Ny no longer crashes when the target year is not a leap year. Also preserve h/m/s/us in offset_n_months so year/month offsets keep the time-of-day (previously dropped, now covered by tests).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9968 +/- ##
==========================================
+ Coverage 85.70% 85.72% +0.02%
==========================================
Files 95 95
Lines 16815 16845 +30
Branches 2577 2581 +4
==========================================
+ Hits 14411 14441 +30
Misses 1668 1668
Partials 736 736 ☔ View full report in Codecov by Harness. |
In case a Since |
Fixes #9967.
Routes the
ycase incalculate_relative_offsetthroughoffset_n_months(from_ts, offset * 12)as suggested in the issue. Result: Feb 29 + Ny no longer crashes when the target year is not a leap year — the day is clamped to the target month's last day (Feb 28 in a non-leap year, Feb 29 in a leap year).Also extended
offset_n_monthsto preserve hour/minute/second/microsecond offrom_ts— otherwise routing the year case through it would have silently dropped time-of-day (and the month case had the same latent gap).Regression tests added in
src/borg/testsuite/helpers/time_test.py.