fix: support compound relative time expressions like -1h30m#16
Merged
Conversation
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.
9fbe227 to
28995f0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--from/--toflags to accept compound relative time expressions (e.g.,-1h30m,-2d3h15m)-30mor-2hwere accepted; compound ones failed with a misleading parse errorDetails
The
RELATIVE_TIME_REGEXwas^([+-])(\d+)([smhdwM])$which only matched a single unit. Changed to^([+-])(\d+[smhdwM])+$with a separateRELATIVE_COMPONENT_REGEXto scan and sum all components.Test plan
-1h30m,-2d3h,-1d2h30m,+1h30mCloses #13