Open
Conversation
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.
Codecov Report❌ Patch coverage is
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
master(or maintenance branch if only applicable there)toxor the relevant test subset)