lead

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func AnchorDate(deadline, scheduled temporal.Date) (temporal.Date, bool)

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

func Canonical(input string) (string, bool)

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 Clock

func Clock(value string) bool

Clock reports a span whose gate is an instant no date can express.

func DateBound

func DateBound(anchor temporal.Date, span string) (temporal.Date, bool)

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

func Describe(span string) (string, bool)

Describe is Humanize with the relationship spelled out, for a sentence that has to say what the span is measured against.

func DisplayDate

func DisplayDate(span string, anchor temporal.Date, hasAnchor bool) (string, bool)

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

func DisplayInstant(span string, anchor temporal.Value, context temporal.Context) (string, bool)

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 Duration

func Duration(value string) (time.Duration, bool)

Duration is a clock span's length, or ok=false for a calendar span.

func GateDate

func GateDate(anchor temporal.Date, span string) (temporal.Date, bool)

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

func GateInstant(anchor temporal.Value, span string, context temporal.Context) (time.Time, bool)

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.

func Humanize

func Humanize(span string) (string, bool)

Humanize renders a stored span: "3 weeks", "1 day". It echoes anything unparsable, matching Recur.humanize so the two fields read the same way.

func Span

func Span(value string) bool

Span reports whether a stored value is a lead span in its exact canonical spelling. Every reader calls this before deriving a gate, so a hand-edited value can never crash a read — Check reports it instead.

Types

type Result

type Result struct {
	Canonical string
	Error     string
}

Result is Parse's outcome: a canonical span, Off, or a reason.

func Parse

func Parse(input string) Result

Parse normalizes user input to a canonical stored span, Off, or a refusal naming why. The refusal text is the user-visible one.

func (Result) IsOff

func (r Result) IsOff() bool

Off reports the clear-the-lead outcome.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL