Skip to content

Today period uses UTC date instead of local timezone — wrong 'today' for non-UTC users #184

@eugene-eee-hongkyu

Description

@eugene-eee-hongkyu

Description

codeburn report --period today returns the date label and daily entry using UTC, ignoring the user's local timezone. For users in non-UTC zones (SGT/KST/etc), this produces a wrong "today" date for several hours each day.

Steps to Reproduce

On a SGT (UTC+8) machine at local time 07:08 (= UTC 23:08 the day before):

$ date
Fri May  1 07:08:14 +08 2026

$ date -u
Thu Apr 30 23:08:15 UTC 2026

$ codeburn report --period today --format json --provider claude

Output:

{
  "period": "Today (2026-04-30)",
  "periodKey": "today",
  "daily": [
    { "date": "2026-04-30", "cost": 50.13, "calls": 180 }
  ]
}

Expected

For a user whose local time is May 1, codeburn today should return 2026-05-01 (and aggregate sessions logged on the user's local May 1).

Actual

codeburn returns 2026-04-30 because it is still April 30 in UTC at that moment. Sessions logged between local midnight and UTC midnight (8 hours in SGT, 9 hours in KST) are bucketed into the previous calendar day, and the user sees yesterday's data labeled as "today".

Impact

  • Users in non-UTC timezones see incorrect "today" data during early-morning hours
  • Daily breakdowns split a single local calendar day across two UTC dates
  • Downstream tooling that chains codeburn output needs to work around this (e.g., we ended up using ccusage's daily output, which already respects local time, as the canonical date source)

Cross-reference

ccusage daily --json (https://www.npmjs.com/package/ccusage), run on the same machine at the same moment, correctly returns date: "2026-05-01" entries. So Date.now() parsing in local time clearly works in npm CLI environments — codeburn appears to compute dates from Date.toISOString() or similar UTC-based formatters.

Suggestion

  • Use the local system timezone by default for date computation (matches user expectation and other ecosystem tools like ccusage)
  • Optional --timezone <iana-zone> flag for explicit override
  • If UTC behavior must remain default for backward compatibility, document it prominently in --help output

Thanks for the great tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions