Skip to content

Y2038+#9430

Open
ThomasWaldmann wants to merge 4 commits intoborgbackup:masterfrom
ThomasWaldmann:y2038
Open

Y2038+#9430
ThomasWaldmann wants to merge 4 commits intoborgbackup:masterfrom
ThomasWaldmann:y2038

Conversation

@ThomasWaldmann
Copy link
Member

@ThomasWaldmann ThomasWaldmann commented Mar 2, 2026

Description

Flip the switch and do not support outdated platforms anymore, see #9429.

Also some minor fixes for time calculations (mainly about avoiding floating point).

Checklist

  • PR is against master (or maintenance branch if only applicable there)
  • New code has tests and docs where appropriate
  • Tests pass (run tox or the relevant test subset)
  • Commit messages are clean and reference related issues

Add utcfromtimestampns() helper that converts nanosecond timestamps to
datetime objects using integer arithmetic (timedelta) instead of floating
point division. This avoids precision loss and potential overflow on 32bit
platforms with old glibc.

Use it in safe_timestamp() and timestamp() instead of datetime.fromtimestamp().

Needed to tweak the timestamps in repo12.tar.gz/test_meta/*.json +/- 1us.
Do not use 1e9 if it is not mean to be a fp calculation anyway, but rather use 10**9 for pure integer calculations.
Not as bad as it sounds:
32bit platforms with 64bit time_t will still work.

As of 2026, this is pretty much any platform that can run borg reasonably well.
in y2262, nanoseconds as signed int64 will overflow.
@ThomasWaldmann ThomasWaldmann changed the title Y2038 Y2038+ Mar 2, 2026
@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 76.52%. Comparing base (ec9e32a) to head (7b69bed).
⚠️ Report is 3 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/helpers/time.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9430   +/-   ##
=======================================
  Coverage   76.52%   76.52%           
=======================================
  Files          85       85           
  Lines       14819    14822    +3     
  Branches     2214     2214           
=======================================
+ Hits        11340    11343    +3     
  Misses       2802     2802           
  Partials      677      677           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant