Skip to content

fix(calendar): use midnight of next day as endOfDay to avoid truncation#510

Closed
dinakars777 wants to merge 1 commit intoopenclaw:mainfrom
dinakars777:fix/calendar-endofday-truncation
Closed

fix(calendar): use midnight of next day as endOfDay to avoid truncation#510
dinakars777 wants to merge 1 commit intoopenclaw:mainfrom
dinakars777:fix/calendar-endofday-truncation

Conversation

@dinakars777
Copy link
Copy Markdown
Contributor

Summary

endOfDay() previously returned 23:59:59.999999999, but FormatRFC3339() uses time.RFC3339 which truncates to second precision, producing 23:59:59. Since the Google Calendar API's timeMax parameter is exclusive, events starting at exactly 23:59:59 are silently dropped from --today, --week, and --days queries.

Impact

This is the root cause of issue #367 where calendar events list returns 404 or missing results when using --today, --from, or --days flags. Events near midnight are silently excluded.

Changes

  • Change endOfDay() to return midnight of the next day (startOfDay(t.AddDate(0, 0, 1))) instead of 23:59:59.999999999
  • This ensures RFC3339 second-precision formatting still includes the entire target day when used as an exclusive timeMax
  • Update existing tests to match the new expected values

Test plan

  • go build ./... compiles cleanly
  • go test ./internal/cmd/... -run TimeRange -v — all pass
  • Manual test: gog calendar events list --today includes events at 23:59
  • Manual test: gog calendar events list --week covers the full week

Closes #367

endOfDay() previously returned 23:59:59.999999999, but FormatRFC3339()
uses time.RFC3339 which truncates to second precision, producing
23:59:59. Since the Calendar API's timeMax is exclusive, events
starting at exactly 23:59:59 were silently dropped from --today,
--week, and --days queries.

Change endOfDay to return midnight of the next day so that RFC3339
formatting preserves the full day range regardless of precision.

Closes openclaw#367
@steipete
Copy link
Copy Markdown
Collaborator

Landed manually on main as part of a grouped calendar fix commit.

Thanks!

@steipete steipete closed this Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: calendar events list returns 404 when using --today, --from, or --days flags

2 participants