fix(daemon): convert cc_info timestamps to UTC before sending to server#196
fix(daemon): convert cc_info timestamps to UTC before sending to server#196
Conversation
The cc_info fetching was sending timestamps with local timezone offset (e.g., "2026-01-04T00:00:00+08:00"), but the server stores data in UTC. If the server doesn't properly parse the timezone offset, it causes a mismatch in the returned data. Now timestamps are converted to UTC before formatting, ensuring the server receives unambiguous UTC values while still respecting the user's local timezone for day/week/month boundaries. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical timezone discrepancy in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a timezone mismatch issue by converting local timestamps to UTC before sending them to the server. The changes in daemon/cc_info_timer.go and model/cc_statusline_service.go are consistent and fix the problem as described. I've added a couple of suggestions to improve code conciseness by inlining the time conversion, which would reduce the number of temporary variables.
| // Convert to UTC before sending to server to avoid timezone parsing issues | ||
| sinceUTC := since.UTC() | ||
| nowUTC := now.UTC() | ||
|
|
||
| variables := map[string]interface{}{ | ||
| "filter": map[string]interface{}{ | ||
| "since": since.Format(time.RFC3339), | ||
| "until": now.Format(time.RFC3339), | ||
| "since": sinceUTC.Format(time.RFC3339), | ||
| "until": nowUTC.Format(time.RFC3339), | ||
| "clientType": "claude_code", | ||
| }, | ||
| } |
There was a problem hiding this comment.
For conciseness, you can inline the .UTC() calls and remove the temporary variables sinceUTC and nowUTC since they are used only once. This makes the code more direct and reduces verbosity.
// Convert to UTC before sending to server to avoid timezone parsing issues
variables := map[string]interface{}{
"filter": map[string]interface{}{
"since": since.UTC().Format(time.RFC3339),
"until": now.UTC().Format(time.RFC3339),
"clientType": "claude_code",
},
}| // Convert to UTC before sending to server to avoid timezone parsing issues | ||
| startOfDayUTC := startOfDay.UTC() | ||
| nowUTC := now.UTC() | ||
|
|
||
| variables := map[string]interface{}{ | ||
| "filter": map[string]interface{}{ | ||
| "since": startOfDay.Format(time.RFC3339), | ||
| "until": now.Format(time.RFC3339), | ||
| "since": startOfDayUTC.Format(time.RFC3339), | ||
| "until": nowUTC.Format(time.RFC3339), | ||
| "clientType": "claude_code", | ||
| }, | ||
| } |
There was a problem hiding this comment.
Similar to the other file, you can make this more concise by inlining the .UTC() calls and removing the temporary variables startOfDayUTC and nowUTC.
// Convert to UTC before sending to server to avoid timezone parsing issues
variables := map[string]interface{}{
"filter": map[string]interface{}{
"since": startOfDay.UTC().Format(time.RFC3339),
"until": now.UTC().Format(time.RFC3339),
"clientType": "claude_code",
},
}
Summary
daemon/cc_info_timer.goandmodel/cc_statusline_service.goTest plan
go test ./daemon/... ./model/...)🤖 Generated with Claude Code