From d68148b62bfcd64b74e12cbeb61eaa784f1c4aed Mon Sep 17 00:00:00 2001 From: DTTerastar Date: Sat, 9 May 2026 11:17:37 -0400 Subject: [PATCH] fix: pass time.Local (not time.UTC) to gocronometer parsers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three call sites in cronoclient.Client hardcoded time.UTC when invoking ExportServingsParsedWithLocation, ExportExercisesParsedWithLocation, and ExportBiometricRecordsParsedWithLocation. The result was that every RecordedTime emitted by these subcommands carried a UTC offset (`...Z`) regardless of the host zone, in direct violation of the timezone contract: https://github.com/quantcli/common/blob/main/CONTRACT.md#2-timezone-policy Beyond the JSON cosmetic, this caused the markdown date-bucketing in cmd/format.go (`r.RecordedTime.Format("2006-01-02")`) to compute the wrong calendar day for any host west of UTC: a record logged at 9pm local on day N bucketed one day late. Fix: time.UTC → time.Local in all three calls. Verified: $ crono-export servings --since 7d --format json | jq '.[0].RecordedTime' "2026-05-02T00:00:00-04:00" # was "2026-05-02T00:00:00Z" Closes #13. Co-Authored-By: Claude Opus 4.7 (1M context) Co-authored-by: Orca --- internal/cronoclient/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/cronoclient/client.go b/internal/cronoclient/client.go index 5e43774..fe417b9 100644 --- a/internal/cronoclient/client.go +++ b/internal/cronoclient/client.go @@ -39,7 +39,7 @@ func (c *Client) Logout() { // Servings returns parsed serving records (one row per food item logged). func (c *Client) Servings(ctx context.Context, rng DateRange) (any, error) { - recs, err := c.inner.ExportServingsParsedWithLocation(ctx, rng.Start, rng.End, time.UTC) + recs, err := c.inner.ExportServingsParsedWithLocation(ctx, rng.Start, rng.End, time.Local) if err != nil { return nil, fmt.Errorf("export servings: %w", err) } @@ -48,7 +48,7 @@ func (c *Client) Servings(ctx context.Context, rng DateRange) (any, error) { // Exercises returns parsed exercise records. func (c *Client) Exercises(ctx context.Context, rng DateRange) (any, error) { - recs, err := c.inner.ExportExercisesParsedWithLocation(ctx, rng.Start, rng.End, time.UTC) + recs, err := c.inner.ExportExercisesParsedWithLocation(ctx, rng.Start, rng.End, time.Local) if err != nil { return nil, fmt.Errorf("export exercises: %w", err) } @@ -57,7 +57,7 @@ func (c *Client) Exercises(ctx context.Context, rng DateRange) (any, error) { // Biometrics returns parsed biometric records (weight, body fat, etc.). func (c *Client) Biometrics(ctx context.Context, rng DateRange) (any, error) { - recs, err := c.inner.ExportBiometricRecordsParsedWithLocation(ctx, rng.Start, rng.End, time.UTC) + recs, err := c.inner.ExportBiometricRecordsParsedWithLocation(ctx, rng.Start, rng.End, time.Local) if err != nil { return nil, fmt.Errorf("export biometrics: %w", err) }