Skip to content

fix: support compound relative time expressions like -1h30m#16

Merged
patrick204nqh merged 1 commit into
mainfrom
fix/compound-relative-time
Feb 11, 2026
Merged

fix: support compound relative time expressions like -1h30m#16
patrick204nqh merged 1 commit into
mainfrom
fix/compound-relative-time

Conversation

@patrick204nqh
Copy link
Copy Markdown
Owner

Summary

  • Fix --from / --to flags to accept compound relative time expressions (e.g., -1h30m, -2d3h15m)
  • Previously only single-unit expressions like -30m or -2h were accepted; compound ones failed with a misleading parse error
  • Update regex to match one or more unit groups and sum their second values

Details

The RELATIVE_TIME_REGEX was ^([+-])(\d+)([smhdwM])$ which only matched a single unit. Changed to ^([+-])(\d+[smhdwM])+$ with a separate RELATIVE_COMPONENT_REGEX to scan and sum all components.

Test plan

  • Existing 35 time parser tests still pass
  • 4 new tests for compound expressions: -1h30m, -2d3h, -1d2h30m, +1h30m
  • Full suite: 161/161 passing

Closes #13

The --from and --to flags only accepted single-unit relative times
(e.g., -30m, -2h). Compound expressions like -1h30m or -2d3h failed
with a misleading parse error, forcing users to convert to single
units or use absolute timestamps.

Update the regex to match one or more unit groups and sum their
values. Closes #13.
@patrick204nqh patrick204nqh force-pushed the fix/compound-relative-time branch from 9fbe227 to 28995f0 Compare February 11, 2026 08:43
@patrick204nqh patrick204nqh merged commit 15de86b into main Feb 11, 2026
2 checks passed
@patrick204nqh patrick204nqh deleted the fix/compound-relative-time branch February 11, 2026 08:44
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.

Support relative time expressions for --to flag

1 participant