Scale fractional timestamp seconds to microseconds - #110
Open
codewithfourtix wants to merge 2 commits into
Open
Conversation
Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the described bug fix and the new tests cover the key fractional-second edge cases in both supported timestamp formats.
Pull request overview
Fixes tstamp2time() so fractional seconds are interpreted as fractions of a second (scaled/padded to 6-digit microseconds) instead of being treated as a raw microsecond integer.
Changes:
- Pad fractional seconds to 6 digits (right-pad with zeros) and truncate beyond 6 digits before applying
datetime.microsecond. - Add tests covering 1–6 digit fractions, leading zeros, and >6 digit truncation across both supported timestamp formats.
File summaries
| File | Description |
|---|---|
src/commoncode/timeutils.py |
Scales/pads/truncates fractional seconds to correctly populate datetime.microsecond. |
tests/test_timeutils.py |
Adds coverage for short fractions, leading zeros, exact microseconds, and extra precision in both timestamp formats. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
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.
tstamp2time()reads.123as 123 microseconds instead of 123 milliseconds. Pad fractional seconds to six digits and truncate extra precision to match datetime microseconds.Adds coverage for short fractions, leading zeros, six-digit fractions, and extra precision in both timestamp formats.