There's a minor bug in helpers.time.calculate_relative_offset() (currently used by borg2 repo-list --oldest/--newest/--older/--newer; possible future use by borg2 check --max-age (#9925) and borg2 prune --keep (#9929)) that raises an error when a year-based interval is applied relative to February 29 and the resulting year is not a leap year.
For example, with from_ts = datetime(2024, 2, 29) and format_string = "1y", the following code raises: ValueError: day 29 must be in range 1..28 for month 2 in year 2025
|
return from_ts.replace(year=from_ts.year + offset) |
Suggested fix:
return offset_n_months(from_ts, offset * 12)
There's a minor bug in
helpers.time.calculate_relative_offset()(currently used byborg2 repo-list --oldest/--newest/--older/--newer; possible future use byborg2 check --max-age(#9925) andborg2 prune --keep(#9929)) that raises an error when a year-based interval is applied relative to February 29 and the resulting year is not a leap year.For example, with
from_ts = datetime(2024, 2, 29)andformat_string = "1y", the following code raises:ValueError: day 29 must be in range 1..28 for month 2 in year 2025borg/src/borg/helpers/time.py
Line 145 in a421c51
Suggested fix: