Documentation
¶
Overview ¶
Package lead is the read-path half of lib/tasks/lead.rb: how long before its occurrence date a task becomes visible.
lead 3w 2d 1m a positive count and a calendar unit
5h or a clock duration in hours
anchor the task's deadline if it has one, else its available-from date
gate anchor - lead, released at local midnight of that date
(a clock lead releases at anchor_instant - duration exactly)
`h` is the one CLOCK unit: `5h` measures a real duration back from the anchor's instant, so it is arithmetic on instants rather than on dates and a gate DATE cannot express it. `m` always means months — never minutes — because a lead shares its unit letters with the recurrence grammar, and overloading one would silently change what an existing stored value means.
parse.go holds the input grammar; this file holds the canonical guard, the unit split, the two gate derivations, and the renderings every surface shows beside a span.
Index ¶
- Constants
- func AnchorDate(deadline, scheduled temporal.Date) (temporal.Date, bool)
- func Canonical(input string) (string, bool)
- func Clock(value string) bool
- func DateBound(anchor temporal.Date, span string) (temporal.Date, bool)
- func Describe(span string) (string, bool)
- func DisplayDate(span string, anchor temporal.Date, hasAnchor bool) (string, bool)
- func DisplayInstant(span string, anchor temporal.Value, context temporal.Context) (string, bool)
- func Duration(value string) (time.Duration, bool)
- func GateDate(anchor temporal.Date, span string) (temporal.Date, bool)
- func GateInstant(anchor temporal.Value, span string, context temporal.Context) (time.Time, bool)
- func Humanize(span string) (string, bool)
- func Span(value string) bool
- type Result
Constants ¶
const Off = "off"
Off is the canonical answer for input that clears the lead. It is not a span, so it is spelled as its own value rather than as an empty string, which a caller could confuse with "no input".
Variables ¶
This section is empty.
Functions ¶
func AnchorDate ¶
AnchorDate is the task's anchor: deadline first, available-from second — the same precedence recurrence completion rolls by, so a task never carries two notions of "its date".
func Canonical ¶
Canonical is Parse for a caller that only wants the answer. ok=false covers both a refusal and the clear-the-lead outcome, which have no span.
func DateBound ¶
DateBound is the earliest calendar date a span's window could open on, for the storable-range guard. It is identical to GateDate for a calendar span; for a CLOCK span it is the date the duration could reach at worst, which is all a range check needs — and needs no zone, which the write path does not have when it runs this check.
func Describe ¶
Describe is Humanize with the relationship spelled out, for a sentence that has to say what the span is measured against.
func DisplayDate ¶
DisplayDate renders a CALENDAR span beside the date it derives: "3 weeks before — opens 2026-10-11". Without a usable anchor it renders the span alone rather than inventing a date.
func DisplayInstant ¶
DisplayInstant renders a CLOCK span beside the wall time it opens at, in the reader's own zone: "5 hours before — opens 2026-05-31 19:00". A clock gate is an instant no date can express, so without a context to project it into there is nothing to render but the span.
func GateDate ¶
GateDate is the date a calendar lead's window opens: the anchor stepped back by the span. Months and years step by Ruby Date#>>, whose day of month CLAMPS to the target month's length rather than overflowing, so a 1m lead before March 31 is February 28 in a common year — exactly the clamp a month-interval recurrence uses.
func GateInstant ¶
GateInstant is the instant a clock lead's window opens: the anchor's own instant minus the duration. RAW — deliberately not rebuilt into a temporal value, which would re-resolve an ambiguous local time and could move the gate by an hour across a DST fall-back. An ALL-DAY anchor resolves to the first instant of its date, so `5h` before June 1 is 19:00 on May 31 local.