Skip to content

feat: --since accepts relative durations (7d, 2w) - #8

Merged
emrehangorgec merged 2 commits into
emrehangorgec:mainfrom
tokentimerch:feat/since-relative-durations
Oct 24, 2026
Merged

emrehangorgec merged 2 commits into
emrehangorgec:mainfrom
tokentimerch:feat/since-relative-durations

Conversation

@tokentimerch

@tokentimerch tokentimerch commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Why

Closes #4.

--since only took an absolute YYYY-MM-DD date. The common case is "the
last week" or "the last 7 days", which meant working out and typing that
date yourself every time.

What

--since now also accepts a relative duration: <n>d or <n>w, resolved
to the UTC date n units ago, inclusive of today - 7d covers today and
the previous 6 days, 2w covers today and the previous 13 days. The
relative form resolves to the same YYYY-MM-DD string the absolute form
already produced, so filtering, the budget guard, and the card's --plan
proration are all untouched downstream of resolveSince.

Invalid input keeps failing with the original error message, extended to
mention the new form: 7x (bad suffix), 0d (zero duration), -3d
(negative), and any other non-match all fall through to
--since expects a valid date in YYYY-MM-DD format (UTC), or a relative duration like 7d or 2w.

Help text and README updated next to the existing --since documentation.

Verification

  • npx tsc --noEmit across all three projects (src, scripts/tsconfig.json,
    test/tsconfig.json) - clean.
  • npx vitest run - all passing except the five pre-existing
    golden.test.ts snapshot failures, which reproduce unchanged on main
    with no code changes (ANSI color codes differ in this shell; unrelated to
    this PR).
  • New tests in test/since.test.ts:
    • rejects malformed relative durations (7x, 0d, 0w, -3d, d, 7,
      7dd, 1.5d)
    • a session exactly on the 7d boundary is included, one day older is
      excluded
    • 1w and 7d produce identical output

Resolves them to the same YYYY-MM-DD string downstream, so filtering, the budget guard and the card's plan window stay unchanged. Invalid input (7x, 0d, -3d) keeps the existing error, now mentioning the relative form.
@tokentimerch
tokentimerch force-pushed the feat/since-relative-durations branch from 1242b17 to 32c6722 Compare October 24, 2026 13:51
@emrehangorgec

Copy link
Copy Markdown
Owner

thanks, looks good! pushed a small fix on top, really big values like 300000000d were crashing it

@emrehangorgec
emrehangorgec merged commit 50c6450 into emrehangorgec:main Oct 24, 2026
9 checks passed
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.

--since should accept relative durations like 7d or 2w

2 participants