Skip to content

Split date resolution by direction: resolveDateAfterNow + resolveDateBeforeNow#134

Open
jallum wants to merge 1 commit into
mainfrom
beadwork-gxn/date-before-now
Open

Split date resolution by direction: resolveDateAfterNow + resolveDateBeforeNow#134
jallum wants to merge 1 commit into
mainfrom
beadwork-gxn/date-before-now

Conversation

@jallum

@jallum jallum commented May 30, 2026

Copy link
Copy Markdown
Owner

What

Splits the date-resolution machinery in cmd/bw/defer.go by direction:

  • Renames the forward-looking resolveDateresolveDateAfterNow (updates all call sites: create.go ×2, update.go ×2, defer.go).
  • Adds its backward-looking mirror, resolveDateBeforeNow, which resolves expressions to the most recent past occurrence:
    • YYYY-MM-DD / RFC3339 passthrough
    • yesterday [at TIME]
    • bare time (3pm) → today if already elapsed, else yesterday
    • N units / N units ago
    • last <weekday> [at TIME]
    • Forward-facing expressions (tomorrow, next monday) are rejected.

Reuses the existing helpers (parseTimeOfDay, parseWeekday, splitAtKeyword) and adds prevWeekday (mirror of nextWeekday) plus parseDurationExprAgo (tolerates a trailing ago).

Why

Prerequisite for a date-based bw archive --before <cutoff> sweep. That cutoff is inherently in the past, and the existing future-facing resolver would mis-handle it dangerously — e.g. resolveDate("2 weeks") returns a date two weeks in the future, which as an archive cutoff would sweep everything. The two directions now have distinct, clearly-named entry points.

Tests

TDD: tests written first (TestResolveDateBeforeNow, TestResolveDateBeforeNowTimeExpressions, TestResolveDateBeforeNowInvalid). Bare-time assertions are written to be timezone-independent (verified passing under UTC, America/New_York, Asia/Tokyo, America/Los_Angeles). Full module suite green; go vet clean.

Ticket: beadwork-gxn

…BeforeNow (beadwork-gxn)

Rename the forward-looking resolveDate to resolveDateAfterNow and add a
backward-looking mirror, resolveDateBeforeNow, that resolves expressions
to the most recent PAST occurrence (yesterday, last <weekday>, N units /
N units ago, bare time today-or-yesterday) alongside YYYY-MM-DD/RFC3339
passthrough. Forward-facing expressions (tomorrow, next monday) are
rejected by the past-facing resolver.

Prerequisite for the date-based 'bw archive --before <cutoff>' sweep,
whose cutoff is inherently in the past and must not reuse the future-
facing resolver.

@iautom8things iautom8things left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 🚀 🚀

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.

2 participants