Skip to content

Commit d68148b

Browse files
DTTerastarorca-ide
andcommitted
fix: pass time.Local (not time.UTC) to gocronometer parsers
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) <noreply@anthropic.com> Co-authored-by: Orca <help@stably.ai>
1 parent dfe32bc commit d68148b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

internal/cronoclient/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (c *Client) Logout() {
3939

4040
// Servings returns parsed serving records (one row per food item logged).
4141
func (c *Client) Servings(ctx context.Context, rng DateRange) (any, error) {
42-
recs, err := c.inner.ExportServingsParsedWithLocation(ctx, rng.Start, rng.End, time.UTC)
42+
recs, err := c.inner.ExportServingsParsedWithLocation(ctx, rng.Start, rng.End, time.Local)
4343
if err != nil {
4444
return nil, fmt.Errorf("export servings: %w", err)
4545
}
@@ -48,7 +48,7 @@ func (c *Client) Servings(ctx context.Context, rng DateRange) (any, error) {
4848

4949
// Exercises returns parsed exercise records.
5050
func (c *Client) Exercises(ctx context.Context, rng DateRange) (any, error) {
51-
recs, err := c.inner.ExportExercisesParsedWithLocation(ctx, rng.Start, rng.End, time.UTC)
51+
recs, err := c.inner.ExportExercisesParsedWithLocation(ctx, rng.Start, rng.End, time.Local)
5252
if err != nil {
5353
return nil, fmt.Errorf("export exercises: %w", err)
5454
}
@@ -57,7 +57,7 @@ func (c *Client) Exercises(ctx context.Context, rng DateRange) (any, error) {
5757

5858
// Biometrics returns parsed biometric records (weight, body fat, etc.).
5959
func (c *Client) Biometrics(ctx context.Context, rng DateRange) (any, error) {
60-
recs, err := c.inner.ExportBiometricRecordsParsedWithLocation(ctx, rng.Start, rng.End, time.UTC)
60+
recs, err := c.inner.ExportBiometricRecordsParsedWithLocation(ctx, rng.Start, rng.End, time.Local)
6161
if err != nil {
6262
return nil, fmt.Errorf("export biometrics: %w", err)
6363
}

0 commit comments

Comments
 (0)