Fix microsecond precision loss in timestamp parsing#223
Merged
wimglenn merged 1 commit intor1chardj0n3s:masterfrom Feb 19, 2026
Merged
Fix microsecond precision loss in timestamp parsing#223wimglenn merged 1 commit intor1chardj0n3s:masterfrom
wimglenn merged 1 commit intor1chardj0n3s:masterfrom
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #223 +/- ##
=======================================
Coverage 94.73% 94.73%
=======================================
Files 1 1
Lines 551 551
Branches 130 130
=======================================
Hits 522 522
Misses 19 19
Partials 10 10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Collaborator
|
Released in 1.21.1. Thanks for your contribution! |
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.
The fractional seconds conversion in date_convert used float arithmetic to turn the decimal portion into microseconds:
This causes precision loss for certain values due to floating-point representation. For example, float('.501902') * 1000000 evaluates to 501901.99999... which int() truncates to 501901 instead of the correct 501902.
The fix avoids float entirely by padding the fractional digits string to 6 characters (or truncating if longer) and converting directly to int:
This handles all cases correctly: fewer than 6 digits get zero-padded, exactly 6 digits pass through unchanged, and more than 6 digits get truncated to microsecond precision.
Includes a regression test covering these cases.
Fixes #162