Format X token as integer seconds (#933)#1297
Open
vineethsaivs wants to merge 1 commit into
Open
Conversation
The `X` (Unix timestamp) format token returned `f"{dt.timestamp()}"`, a float
like `1614556907.369226`, so `format("X")` leaked a fractional part and tokens
such as `XSSS` produced a stray dot and extra digits (e.g.
`1614556907.369226369`). This was a regression from 0.17.0, which emitted whole
seconds.
Return integer seconds (`int(dt.timestamp())`), matching the documented token
and pre-1.0 behavior. `XSSS` now yields `1614556907369` again.
Fixes arrow-py#933
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1297 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2315 2315
Branches 358 358
=========================================
Hits 2315 2315 ☔ View full report in Codecov by Harness. |
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.
Issue Description
Fixes #933.
The
X(Unix timestamp) format token returnedf"{dt.timestamp()}", which is a float:format("X")leaked the fractional part, and composite tokens likeXSSSproduced a stray dot and trailing digits. As noted in the issue, this was a regression from 0.17.0, which emitted whole seconds.Fix
Return integer seconds (
int(dt.timestamp())), matching the documentedXtoken (Unix timestamp) and the pre-1.0 behavior:Parsing is unaffected (
arrow.get("1614556907", "X")still round-trips, and the parser still accepts fractional timestamps).Tests
Updated
tests/test_formatter.py::test_timestampto assert whole-second output forX(it previously asserted the float). All 623 formatter tests pass.Disclosure: prepared with AI assistance; reviewed by me and I can explain every line.