Skip to content

feat(calendar): add --sort / --order for events listing#581

Merged
steipete merged 2 commits into
openclaw:mainfrom
gado-ships-it:feat/calendar-events-sort
May 14, 2026
Merged

feat(calendar): add --sort / --order for events listing#581
steipete merged 2 commits into
openclaw:mainfrom
gado-ships-it:feat/calendar-events-sort

Conversation

@gado-ships-it
Copy link
Copy Markdown
Contributor

@gado-ships-it gado-ships-it commented May 13, 2026

Summary

gog calendar events --all aggregates events from every calendar, but the result comes back in CalendarList iteration order (one calendar's events as a block, then the next). That makes the merged view unusable for agents/humans who want a single chronological list across calendars — the original motivation here was planning "today from now on" via an LLM agent.

This PR:

  • Adds --sort=start|end|summary|calendar and --order=asc|desc to calendar events. With --sort=start, events from all calendars interleave by absolute instant (parsed through the existing parseEventTime / parseEventDate helpers so RFC3339 with offset, RFC3339Nano, and all-day 2006-01-02 dates compare correctly across timezones).
  • Documents now in the --from / --to help strings for both calendar events and the shared TimeRangeFlags. timeparse.ParseRangeExpr already resolves now, but the help only listed today, tomorrow, monday, so the precise "from this instant onward" form was invisible to anyone reading --help.
  • Removes an unused wrapEventsWithTimezone helper that lost its only call site after the JSON path was restructured to share wrapping with the table path.

Default sort is empty so existing behavior is unchanged; the help string flags start as the recommended value with --all.

Example (placeholder data):

$ gog calendar events --all --from=now --sort=start --max=5 -p
CALENDAR     ID   START                       END                         SUMMARY
work-cal     ...  2026-05-13                  2026-05-14                  All-day deadline
personal-cal ...  2026-05-14T16:00:00Z        2026-05-14T16:30:00Z        Standup
team-cal     ...  2026-05-15T09:00:00+02:00   2026-05-15T17:00:00+02:00   Offsite
holidays     ...  2026-05-18T10:30:00Z        2026-05-18T11:00:00Z        Workshop

Test plan

  • make fmt clean
  • make lint clean (no new issues)
  • make test green
  • New TestListAllCalendarsEvents_SortByStart covers --sort=start --order=asc + --order=desc against a two-calendar fixture where the API returns late before early.
  • New TestSortEventsBy_Summary covers case-insensitive summary sort + reverse.
  • Smoke-tested live against a multi-calendar Google account spanning personal, team, and holiday calendars: events interleave correctly across +02:00, Z, and all-day formats.

🤖

salam and others added 2 commits May 13, 2026 23:38
`calendar events --all` aggregates events from every calendar, but the
result was returned in calendar-iteration order (each calendar's events
appear as a block, in the order CalendarList returned them). That makes
the output unusable when an agent or user wants a single chronological
view across calendars.

Add `--sort=start|end|summary|calendar` plus `--order=asc|desc` to
`calendar events`. With `--sort=start`, events from all calendars are
interleaved by absolute instant (parsed via the existing parseEventTime /
parseEventDate helpers, so RFC3339 with offset, RFC3339Nano, and all-day
dates all compare correctly across timezones).

Default `--sort=""` preserves prior behavior; the help string notes that
`start` is the recommended value with `--all`.

Also document `now` in the `--from` / `--to` help strings for both
`calendar events` and the shared TimeRangeFlags. `timeparse` already
resolves `now`, but the help only listed `today, tomorrow, monday`, so
agents (and humans reading `--help`) had no signal that the precise
"from this instant onward" form was available.

Tests:

- TestListAllCalendarsEvents_SortByStart asserts that events from two
  calendars interleave chronologically with --sort=start, and that --order=desc
  reverses the order.
- TestSortEventsBy_Summary covers case-insensitive summary sort and reverse.
- Existing TestListAllCalendarsEvents_JSON and TestListCalendarEvents_*
  continue to pass; their signatures gained two trailing empty strings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@steipete steipete merged commit 6e416bd into openclaw:main May 14, 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.

3 participants