feat(period): support absolute date ranges in --period flag#674
Conversation
Overload the existing --period flag across all 8 time-scoped commands to accept absolute date ranges using gh-compatible syntax, in addition to existing relative durations. New formats: "2024-01-01..2024-02-01", ">=2024-01-01", ">2024-01-01", "<=2024-02-01", "<2024-02-01", and open-ended "2024-01-01.." / "..2024-02-01". - Add src/lib/time-range.ts with parsePeriod(), timeRangeToApiParams(), serializeTimeRange(), and timeRangeToSeconds() - Add start/end params to all API function option types - Update all 8 commands: trace list, span list, issue events, event list, issue list, trace logs, log list, dashboard view - Date-only inputs use local timezone (not UTC) - Exclusive operators (>, <) shift to next/prev day for date-only - Follow mode rejects end-bounded ranges - 67 tests (34 unit + 33 property-based)
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛Init
Other
Internal Changes 🔧Init
Other
Other
🤖 This preview updates automatically when you update the PR. |
|
Codecov Results 📊✅ 134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 89.72%. Project has 1459 uncovered lines. Files with missing lines (4)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 95.56% 95.50% -0.06%
==========================================
Files 222 223 +1
Lines 32111 32414 +303
Branches 0 0 —
==========================================
+ Hits 30686 30955 +269
- Misses 1425 1459 +34
- Partials 0 0 —Generated by Codecov Action |
…Date parsing Replace RELATIVE_PERIOD_RE, DATE_ONLY_RE, and HAS_TZ_RE with simpler string-based checks and a parseRelativeParts() helper that uses String.at(), Number(), and String.includes().
…one detection Remove hasTimezone(), getLocalOffsetString(), and isDateOnly() in favor of letting new Date() handle timezone interpretation natively. All outputs are now UTC via .toISOString() — no manual offset string construction.
- Fix statsPeriod/start+end conflict: API functions with fallback statsPeriod defaults now guard with start/end presence check - Fix normalizeDateOnly day arithmetic: use local setDate/setHours instead of UTC round-trip to prevent date shift in extreme timezones - Reject all absolute ranges with --follow, not just end-bounded
- Fix dashboard: use period (not statsPeriod) for WidgetQueryOptions,
matching the expected interface field name
- Fix log list: add period context to empty-state message ("No logs
found in the last 30d." / "No logs found in the specified range.")
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 285982c. Configure here.
- Make PERIOD_BRIEF and all error message dates dynamic (relative to today) - Use new Set(Object.keys(UNIT_SECONDS)) for PERIOD_UNITS - Remove unnecessary ?? on .at(-1) (use as-cast, length pre-checked) - Accept space separator as T alternative in datetime parsing - Add test for space-separated datetime input

Summary
Overload the existing
--periodflag across all 8 time-scoped commands to accept absolute date ranges usinggh-compatible syntax (e.g.,gh search issues --created ">2023-01-01"), in addition to existing relative durations.New syntax
7d,24h--period 7ddate..date--period "2024-01-01..2024-02-01"date../..date--period "2024-01-01..">=date--period ">=2024-01-01">date--period ">2024-01-01"<=date--period "<=2024-02-01"<date--period "<2024-02-01"Date formats:
YYYY-MM-DD,YYYY-MM-DDTHH:MM:SS, with optional timezone.Key design decisions
--start/--endflags, avoids alias conflicts and--helpclutter"2024-01-15"means the user's local midnight, not UTC>2024-01-15(date-only) starts from Jan 16;>2024-01-15T12:00:00Z(datetime) passes through as-islog list --followrejects end-bounded ranges>=2024-01-01and2024-01-01..share the same cache entryAffected commands (8)
trace list,span list,issue events,event list,issue list,trace logs,log list,dashboard viewChanges
src/lib/time-range.ts—parsePeriod(),timeRangeToApiParams(),serializeTimeRange(),timeRangeToSeconds()start?/end?to all option types inapi/traces.ts,api/events.ts,api/issues.ts,api/logs.ts,api/dashboards.tsparsePeriod(), spread API params viatimeRangeToApiParams(), serialize for pagination viaserializeTimeRange()