Repository navigation
fix(cli): reject unknown --timezone values - #1735
Conversation
parse_tz swallowed the jiff error, so an unknown name such as a typo in America/New_York silently fell back to the system timezone and could group usage under the wrong date, with no error and no warning. The check runs once in the binary after config and flags are merged, next to the existing --last resolver, because the parser crate deliberately has no timezone dependency. It covers the shared flag, the statusline flag, and a config timezone, and only inspects the value the command will actually use. `local` stays accepted as the documented name for the system timezone.
Co-authored-by: Saurav Sharma <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | 56124d9 | Commit Preview URL Branch Preview URL |
Sep 16 2026, 01:27 AM |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe change validates effective timezone values from CLI arguments and configuration files. It preserves ChangesTimezone validation
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant CliParser
participant TimezoneValidator
participant DateUtils
participant UsageExit
CliParser->>TimezoneValidator: Validate effective timezone
TimezoneValidator->>DateUtils: Call is_valid_timezone
DateUtils-->>TimezoneValidator: Return validation result
TimezoneValidator->>UsageExit: Return usage error when invalid
Merge Risk: ⚪ Minimal · up to Timezone validation and statusline timezone propagation retain the configured value and root-flag override behavior, with no actionable current-head merge risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 Clippy (1.98.0)Clippy execution failed Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ Minor suggestions only — validation logic looks correct.
Reviewed changes
Reviewed
fix(cli): reject unknown --timezone valuesfor silent system-timezone fallback on typos.
- Core validation helper — new
is_valid_timezoneacceptslocalandUTCwithout a zoneinfo lookup and checks everything else viaJiffTimeZone::get.- Fallback-free parsing —
parse_tznow mapslocalto system andUTCtoTimeZone::UTCdirectly instead of a fallible lookup.- Single CLI checkpoint — new
cli/timezonemodule validates the effective timezone once after config and flag merge, covering root flags, per-command flags, and config file values.- Docs — documents rejection of unknown names with a non-zero exit.
ℹ️ Nitpicks
- The docs paragraph says the value must be an IANA name or
local, while the code special-casesUTCas always accepted without a zoneinfo lookup. NamingUTCalongsidelocalin that sentence would match the error message and the implementation.
Muse Spark Contributor (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
ccusage
@ccusage/ccusage-darwin-arm64
@ccusage/ccusage-darwin-x64
@ccusage/ccusage-linux-arm64
@ccusage/ccusage-linux-x64
@ccusage/ccusage-win32-x64
commit: |
ccusage performance comparisonPR SHA: Performance comparison skipped. Base package URL was not ready before 300.000s. Fixture performance comparison requires a base package when --base-dir is not provided. Base package: |
ccusage performance comparisonPR SHA: Performance comparison skipped. Base package URL was not ready before 300.000s. Fixture performance comparison requires a base package when --base-dir is not provided. Base package: |
ccusage performance comparisonPR SHA: Performance comparison skipped. Base package URL was not ready before 300.000s. Fixture performance comparison requires a base package when --base-dir is not provided. Base package: |
ccusage performance comparisonPR SHA: Performance comparison skipped. Base package URL was not ready before 300.000s. Fixture performance comparison requires a base package when --base-dir is not provided. Base package: |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since the prior pullfrog review (a16c963 → 56124d9).
- Preserved root timezone for statusline — the
statuslineparser branch now clones the rootshared.timezoneintoStatuslineArgsafter config application, soccusage --timezone <value> statuslineis honored and validated like every other subcommand. - Extended timezone validation tests — rejection and acceptance cases now cover the root flag placed before
statuslinein both directions.
Muse Spark Contributor (free via Pullfrog for OSS) | 𝕏
ccusage performance comparisonPR SHA: Performance comparison skipped. Base package URL was not ready before 300.000s. Fixture performance comparison requires a base package when --base-dir is not provided. Base package: |
ccusage performance comparisonPR SHA: Performance comparison skipped. Base package URL was not ready before 300.000s. Fixture performance comparison requires a base package when --base-dir is not provided. Base package: |

Closes #1730.
This carries forward #1732 by @ravsau, preserving the original commit author, and fixes the Linux CI regression found by the full workflow. The documented
UTCvalue was being validated through the host zoneinfo database and could be rejected even though it is always supported by jiff.The follow-up treats
UTCas the built-in UTC timezone andlocalas the explicit system-timezone fallback, without relying on a zoneinfo lookup.Validation:
zcode_cliintegration testcargo test -p ccusage-core -p ccusage(all passed)just hawk(0 findings)Summary by cubic
Closes #1730. Unknown
--timezonevalues now fail with a clear error and non-zero exit code instead of silently falling back to the system timezone and grouping usage under the wrong date.--timezone/-zflags, thestatuslineflag, and config filetimezone.statuslinenow inherits the root--timezonevalue before its own-zflag applies.UTCis always accepted without a zoneinfo lookup;localremains the documented system-timezone fallback.Written for commit 56124d9. Summary will update on new commits.
Summary by CodeRabbit
New Features
local,UTC, or an unset timezone.Bug Fixes
statuslineunless overridden.Documentation