Skip to content

Scale fractional timestamp seconds to microseconds - #110

Open
codewithfourtix wants to merge 2 commits into
aboutcode-org:mainfrom
codewithfourtix:fix-timestamp-fractional-seconds
Open

Scale fractional timestamp seconds to microseconds#110
codewithfourtix wants to merge 2 commits into
aboutcode-org:mainfrom
codewithfourtix:fix-timestamp-fractional-seconds

Conversation

@codewithfourtix

Copy link
Copy Markdown

tstamp2time() reads .123 as 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.

Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
Copilot AI lite review requested due to automatic review settings September 5, 2026 17:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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>
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.

2 participants