Split date resolution by direction: resolveDateAfterNow + resolveDateBeforeNow#134
Open
jallum wants to merge 1 commit into
Open
Split date resolution by direction: resolveDateAfterNow + resolveDateBeforeNow#134jallum wants to merge 1 commit into
jallum wants to merge 1 commit into
Conversation
…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.
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.
What
Splits the date-resolution machinery in
cmd/bw/defer.goby direction:resolveDate→resolveDateAfterNow(updates all call sites:create.go×2,update.go×2,defer.go).resolveDateBeforeNow, which resolves expressions to the most recent past occurrence:YYYY-MM-DD/ RFC3339 passthroughyesterday[at TIME]3pm) → today if already elapsed, else yesterdayN units/N units agolast <weekday>[at TIME]tomorrow,next monday) are rejected.Reuses the existing helpers (
parseTimeOfDay,parseWeekday,splitAtKeyword) and addsprevWeekday(mirror ofnextWeekday) plusparseDurationExprAgo(tolerates a trailingago).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 vetclean.Ticket: beadwork-gxn