Skip to content

fix: normalize timezone-aware usage date labels#258

Merged
robinebers merged 2 commits intorobinebers:mainfrom
sonwr:fix/timezone-usage-label-boundary
Mar 4, 2026
Merged

fix: normalize timezone-aware usage date labels#258
robinebers merged 2 commits intorobinebers:mainfrom
sonwr:fix/timezone-usage-label-boundary

Conversation

@sonwr
Copy link
Contributor

@sonwr sonwr commented Mar 3, 2026

Problem

Some usage entries with timezone-aware timestamps (e.g. ...Z, ...+09:00, ...-08:00) can be labeled under the wrong day key around day/month boundaries.

Root cause

Date key parsing only handled a narrow ISO shape, so timezone-bearing datetime strings were not consistently normalized to YYYY-MM-DD before day-bucket matching.

Fix

  • Added support for ISO datetime prefixes (YYYY-MM-DD followed by T, t, or whitespace) in date key extraction.
  • Applied the same normalization fix to both Claude and Codex plugins.

Tests

Added regression tests for both plugins covering boundary cases:

  • UTC timestamp (Z)
  • UTC+9 timestamp
  • UTC-8 timestamp

Test command run locally:

  • bun run test plugins/claude/plugin.test.js plugins/codex/plugin.test.js
  • Result: 102 passed

Impact

More reliable day-label attribution for usage metrics across timezones, especially near day/month boundaries.

Fixes #254


Summary by cubic

Fixes wrong day labels for usage entries with timezone-aware timestamps by normalizing date parsing in the Claude and Codex plugins. Daily buckets like Today are now correct across timezones, including at day/month boundaries.

  • Bug Fixes
    • Parse ISO datetimes starting with YYYY-MM-DD followed by T/t/space and normalize to YYYY-MM-DD for matching.
    • Apply the same normalization in both plugins.
    • Add regression tests for Z, +09:00, and -08:00 boundary cases.

Written for commit 75d2072. Summary will update on new commits.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

@augmentcode
Copy link

augmentcode bot commented Mar 3, 2026

🤖 Augment PR Summary

Summary: Fixes incorrect day labeling for usage entries whose date values are full ISO datetimes with timezones.

Changes:

  • Extended `dayKeyFromUsageDate()` to also extract a `YYYY-MM-DD` prefix when the input is `YYYY-MM-DD` followed by T/t or whitespace (e.g. ...Z, ...+09:00, ...-08:00).
  • Applied the same normalization logic in both the Claude and Codex plugins to keep behavior consistent.
  • Added regression tests in both plugin test suites covering UTC, UTC+9, and UTC-8 timestamps near day/month boundaries.

Technical Notes: This change avoids falling back to Date.parse() for ISO datetime strings (which can shift the day when converted to local time), ensuring stable day-bucket matching based on the date portion of the input string.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@davidarny
Copy link
Collaborator

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Collaborator

@davidarny davidarny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks clean, thanks!

@robinebers
Copy link
Owner

I'd love to see some examples and/or screenshots to visualize this.

@cubic-dev-ai review

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Mar 3, 2026

I'd love to see some examples and/or screenshots to visualize this.

@cubic-dev-ai review

@robinebers I have started the AI code review. It will take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Copy link
Owner

@robinebers robinebers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@robinebers robinebers merged commit 9e35cea into robinebers:main Mar 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timezone might be not taken into account in next reset date at least for Copilot

3 participants