Skip to content

fix: convert timestamps to UTC before formatting (#221) - #222

Open
drewr wants to merge 2 commits into
mainfrom
fix/issue-221-local-time-labelled-z
Open

fix: convert timestamps to UTC before formatting (#221)#222
drewr wants to merge 2 commits into
mainfrom
fix/issue-221-local-time-labelled-z

Conversation

@drewr

@drewr drewr commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Closes #221

Summary

  • Each timestamp used Format("2006-01-02T15:04:05Z"). In Go this treats the trailing Z as a literal character, not a zone verb, so the output shows the local clock time regardless of timezone.
  • metav1.Time and metav1.MicroTime store times in the local zone after JSON decoding (UnmarshalJSON calls .Local()), so the formatted output shows the wrong day/clock time while still printing Z.
  • The fix converts to UTC first, then formats with time.RFC3339, which correctly emits Z only when the time is UTC.

Changes

  • ef1f5f9 test: Add non-UTC timestamp test cases to TestActivitiesToRows, TestEventsToRows, and TestKubeEventsToRows that expect the correct UTC instant. These tests fail before the fix and pass after.
  • 70c8a18 fix: Replace all 14 occurrences of Format("2006-01-02T15:04:05Z") with .UTC().Format(time.RFC3339) across 5 files in pkg/cmd/, pkg/cmd/reindexjob/, and pkg/mcp/tools/.

drewr added 2 commits August 3, 2026 16:06
Add non-UTC timestamp test cases to TestActivitiesToRows,
TestEventsToRows, and TestKubeEventsToRows that expect the
correct UTC output. These fail until the Format literal-Z
in each respective function is fixed.
Replace all 14 occurrences of Format("2006-01-02T15:04:05Z") with
.UTC().Format(time.RFC3339). The bare Z in the old layout is a literal
character, not a zone verb, so local clock times were printed with a Z
suffix that falsely claimed they were UTC.
@drewr
drewr requested review from JoseSzycho and scotwells August 3, 2026 21:11
@JoseSzycho

JoseSzycho commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

We should document somewhere our preferred method for storing/displaying times

@drewr

drewr commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

A good addition to our style guide!

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.

activity prints local time and labels it Z

2 participants