fix: parse --start/--end in local time#5
Merged
Merged
Conversation
Previously, time.ParseInLocation(..., time.UTC) meant --start 2025-01-01 resolved to UTC midnight — which in EDT is Dec 31 at 8pm local. The API received the wrong calendar boundary, silently shifting results by one day for users west of UTC. Parse with ref.Location() so absolute dates match the user's local calendar, consistent with --today (which was already local) and with the package docstring's explicit promise. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
DTTerastar
added a commit
that referenced
this pull request
May 19, 2026
Review feedback on #44: - **Must fix #1: README.md stale.** Replaced the "no token cache" paragraph with the cache location ($XDG_CACHE_HOME), the CRONOMETER_NO_CACHE opt-out, the `auth logout` subcommand, and a security note ("treat session.json like a password"). Folds in the reviewer's nice-to-have #5 (security guidance) at the same time. - **Must fix #2: gofmt.** Ran `gofmt -w` on `cmd/format.go` and `internal/cronoclient/daterange_test.go` (trailing blank line + struct field alignment). `internal/cronoapi/gwt.go` is also flagged but is pre-existing from #37 — landed as a separate chore commit so this PR's diff stays scoped to release-blocker work. - **Nice-to-have #4: cache schema version.** Added `cacheSchemaVersion = 1` and a `Version int` field on cachedSession. Old/mismatched versions are silently treated as a miss so a future incompatible bump triggers a transparent re-login instead of a JSON-shape error. New test: TestSessionCacheVersionMismatch. Skipped: race on concurrent fresh logins (#6) — reviewer agreed this is fine for a single-user CLI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9 tasks
DTTerastar
added a commit
that referenced
this pull request
May 19, 2026
* feat: release-blocker bundle for v0.2.0 (#17 #18 #21 #16 #15 #23 #39 #40) Bundles eight ship-blocker fixes called out in the QA triage on main: - **#39 session cache (major):** persist auth/cookies to $XDG_CACHE_HOME/crono-export/session.json (mode 0600), retry-on-stale, CRONOMETER_NO_CACHE escape hatch, new `auth logout` subcommand. Fixes the rate-limit foot-gun where 5–6 back-to-back calls trip Cronometer's throttle. Also de-duplicates the "login failed: login failed:" wrap. - **#17 typed nutrition/notes JSON (breaking):** csvToJSON now returns []map[string]any with best-effort coercion (numeric → float64, true/false → bool, empty → null). Drops the contract drift where two of five subcommands forced jq `tonumber` on every column. - **#15 + #23 validation before login:** Args=cobra.NoArgs + a PreRunE that calls chosenFormat — bad --format / positional args now exit fast without burning a Cronometer login attempt. - **#16 + #18 + #21 contract-violation trio:** empty markdown is silent on stdout (friendly note → stderr); --until alone uses 7d window ending at --until (was 1-day); inverted --since/--until warns to stderr and returns empty + exit 0 (was non-zero error). - **#40 VitaminDIU cosmetic:** strippedSuffix table had "UI" instead of the standard "IU" abbreviation; vitamin D markdown was rendering without splitting the unit. Added TestStrippedSuffix to cover. - **#19 closed as part-fixed/part-wontfix:** zone-as-UTC was already fixed by the clean-room rewrite (#37); the wire CSV carries no time-of-day to surface. Documented in prime GOTCHAS. New tests cover: strippedSuffix (cmd), resolveDateRange (cronoclient), coerceCSVValue + csvToJSON (cronoclient), session cache round-trip (cronoclient). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fixup: address PR review — README, gofmt, cache schema version Review feedback on #44: - **Must fix #1: README.md stale.** Replaced the "no token cache" paragraph with the cache location ($XDG_CACHE_HOME), the CRONOMETER_NO_CACHE opt-out, the `auth logout` subcommand, and a security note ("treat session.json like a password"). Folds in the reviewer's nice-to-have #5 (security guidance) at the same time. - **Must fix #2: gofmt.** Ran `gofmt -w` on `cmd/format.go` and `internal/cronoclient/daterange_test.go` (trailing blank line + struct field alignment). `internal/cronoapi/gwt.go` is also flagged but is pre-existing from #37 — landed as a separate chore commit so this PR's diff stays scoped to release-blocker work. - **Nice-to-have #4: cache schema version.** Added `cacheSchemaVersion = 1` and a `Version int` field on cachedSession. Old/mismatched versions are silently treated as a miss so a future incompatible bump triggers a transparent re-login instead of a JSON-shape error. New test: TestSessionCacheVersionMismatch. Skipped: race on concurrent fresh logins (#6) — reviewer agreed this is fine for a single-user CLI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: gofmt internal/cronoapi/gwt.go (preexisting drift from #37) Pure formatting: column-aligned const block and var block. No logic change. Flagged by `gofmt -l .` during review of #44. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
time.ParseInLocation(..., time.UTC)→time.ParseInLocation(..., ref.Location())inresolveDateRange, so absolute--start/--endflags resolve to the user's local midnight.--todayalready had (line 47 already usedref.Location()) and the explicit promise in the package docstring.Before, a user in EDT running `--start 2025-01-01` asked Cronometer for the window starting at 2024-12-31 20:00 local — silently off by a day.
Test plan
🤖 Generated with Claude Code