Skip to content

fix: render task timestamps in local time - #283

Merged
ryanlewis merged 1 commit into
mainfrom
claude/blissful-mccarthy-kr45w0
Sep 30, 2026
Merged

ryanlewis merged 1 commit into
mainfrom
claude/blissful-mccarthy-kr45w0

Conversation

@ryanlewis

Copy link
Copy Markdown
Owner

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() on CreationDate and StopDate before formatting to convert UTC timestamps to the reader's local time
  • internal/output/output_test.go:
    • Updated existing test to use time.Local instead of time.UTC for consistency
    • Added TestPrintTaskDetail_TimestampsInLocalTime to verify correct rendering across timezone boundaries (UTC task stopped at 23:30 displays as 00:30 in BST)
  • internal/output/golden_test.go:
    • Pinned time.Local to UTC during golden file rendering to ensure test output is deterministic and independent of the machine's timezone
    • Updated goldenNow to use time.UTC for clarity

Implementation 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.UTC to ensure reproducible output regardless of where tests run.

https://claude.ai/code/session_018RvSqggD6JoEe6oW8nfN7g

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
@ryanlewis
ryanlewis merged commit 30843a2 into main Sep 30, 2026
8 checks passed
@ryanlewis
ryanlewis deleted the claude/blissful-mccarthy-kr45w0 branch September 30, 2026 02:46
@ryanlewis ryanlewis added bughunt Found by the weekly bughunt routine fix Bug fix labels Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bughunt Found by the weekly bughunt routine fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants