--until <date> flag for arbitrary date ranges - #41
Open
dchaudhari7177 wants to merge 1 commit into
Open
Conversation
Owner
|
Conflict against main now — a few other PRs touching |
loadReport already supported an exclusive 'until' bound — wrapped --month used it internally via monthRange — but it was not reachable from the CLI, so a report could only be bounded from below with --since. Expose --until and thread it into loadReport alongside since, for every command rather than just wrapped. --month still wins when both are given, matching how --since already behaves. Both bounds now get a shared date check. They are compared as string prefixes against ISO timestamps, so a year or year-month is as valid as a full date (monthRange depends on that); the check accepts those three shapes and rejects the typo that would otherwise sort above every timestamp and silently empty the report. Closes notsointresting#32
dchaudhari7177
force-pushed
the
feat/until-flag
branch
from
July 23, 2026 15:32
c329b7d to
0e20378
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.
loadReportalready accepts an exclusiveuntilbound —wrapped --monthuses it internally viamonthRange()— it just wasn't reachable from the CLI, so a report could only be bounded from below.Changes
--until <date>is parsed and threaded intoloadReport()alongsidesince, for every command, not justwrapped.--monthstill wins when both are supplied, matching how--sincealready behaves.ignore activity from this date onward), which is the existingLoadOptions.untilsemantic. So "just last week" is--since 2026-07-14 --until 2026-07-21→ the 14th through the 20th. Say the word if you'd rather it were inclusive and I'll add the +1-day conversion.On validation
The issue says "validated the same way
--sinceis" —--sincecurrently isn't validated at all, and that's a quiet footgun: bounds are compared as string prefixes against ISO timestamps, so--since last-tuesdaysorts above every timestamp and silently returns an empty report rather than erroring.So I added one shared check applied to both bounds. It stays lenient about shape on purpose —
YYYY,YYYY-MMandYYYY-MM-DDare all accepted, because the comparison really is a prefix match andmonthRangeitself passesYYYY-MM. Only genuinely non-date input is rejected.That does mean
--sincenow rejects garbage it previously swallowed. I think that's the fix, but it's a behaviour change on an existing flag — happy to scope it back to--untilonly if you'd prefer.Tests
In
test/cli.test.ts:--untilbounds from above, combines with--sincefor a window (including an emptysince == untilwindow, proving exclusivity), works on a non-wrappedcommand, rejects malformed values on both bounds, and accepts year / year-month / full-date prefixes.Typecheck and the full suite (86 passing) are green.
Closes #32