Repository navigation
fix: render task timestamps in local time - #283
Merged
Merged
Conversation
The detail block printed CreationDate and StopDate as model.UnixToTime returns them, in UTC, with no zone on the line. Every other date a reader sees is local, so in a zone ahead of UTC an item closed shortly after midnight read as stopped the day before (00:30 BST showed 23:30 on the previous date). Render both in local time. The golden render now pins time.Local to UTC so the document does not change with the zone of the machine running the tests, and a new test covers the day-boundary case under a fixed +01:00 zone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RvSqggD6JoEe6oW8nfN7g
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.
Summary
Task creation and stop dates are stored in UTC but displayed without timezone information in the detail block. This caused misinterpretation in timezones ahead of UTC — a task stopped after midnight BST would display as stopped the previous day.
Changes
internal/output/output.go: Call.Local()onCreationDateandStopDatebefore formatting to convert UTC timestamps to the reader's local timeinternal/output/output_test.go:time.Localinstead oftime.UTCfor consistencyTestPrintTaskDetail_TimestampsInLocalTimeto verify correct rendering across timezone boundaries (UTC task stopped at 23:30 displays as 00:30 in BST)internal/output/golden_test.go:time.Localto UTC during golden file rendering to ensure test output is deterministic and independent of the machine's timezonegoldenNowto usetime.UTCfor clarityImplementation Details
The fix leverages the fact that
time.Time.Local()converts a UTC timestamp to the local timezone while preserving the wall-clock instant. The detail block prints timestamps without zone information (e.g., "2026-09-30 00:30"), so they must be rendered in local time to match the reader's perception of "today" and other relative dates shown elsewhere in the output.Golden file tests now explicitly set
time.Local = time.UTCto ensure reproducible output regardless of where tests run.https://claude.ai/code/session_018RvSqggD6JoEe6oW8nfN7g