Documentation
¶
Overview ¶
Package isnow implements the DTimpalr date/time pattern language: an isnow holds at an instant when every field constraint is satisfied. The defining operation is the membership test, Pattern.Holds(at); Next/Prev derive occurrences from it. See github.com/tsvsheet/isnow (SPECIFICATION.md) for the language and specs/contracts/ for the pinned semantics.
Index ¶
- Constants
- func Code(err error) string
- func Is(src string, at time.Time) (bool, error)
- type Pattern
- func (p Pattern) Canonical() string
- func (p Pattern) Explain() string
- func (p Pattern) Holds(at time.Time) bool
- func (p Pattern) Next(from time.Time) (time.Time, bool)
- func (p Pattern) NextContext(ctx context.Context, from time.Time) (time.Time, bool, error)
- func (p Pattern) Prev(from time.Time) (time.Time, bool)
- func (p Pattern) PrevContext(ctx context.Context, from time.Time) (time.Time, bool, error)
- func (p Pattern) String() string
Constants ¶
const ( // ErrSyntax is a malformed pattern the grammar rejects. ErrSyntax errs.Const = "syntax" // ErrSymbol is an unknown or ambiguous weekday/time/unit name. ErrSymbol errs.Const = "symbol" // ErrRange is a value outside its field's domain. ErrRange errs.Const = "range" // ErrContext is a grammatical but semantically invalid construct. ErrContext errs.Const = "context" )
The four stable error codes every implementation shares (specs/contracts/ semantics.md). Callers match with errors.Is.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Pattern ¶
type Pattern struct {
// contains filtered or unexported fields
}
Pattern is a parsed, canonicalized isnow. The zero value is not usable; obtain one from Parse. Patterns are immutable and safe to copy and share.
func Parse ¶
Parse recognizes src, resolves symbols and the shorthand ladder, and validates field domains. It returns one of ErrSyntax, ErrSymbol, ErrRange, or ErrContext.
func (Pattern) Explain ¶
Explain returns a deterministic English description of the isnow, built from the terminology vocabulary. The wording is implementation-defined (not pinned by the conformance corpus).
func (Pattern) Holds ¶
Holds reports whether the isnow holds at the instant: every field constraint and every bound is satisfied. The instant is evaluated in its own location (at.Location()) and truncated to whole seconds.
func (Pattern) Next ¶
Next returns the earliest occurrence strictly after from, or false when none exists within the pattern's window or the 100-year horizon.
func (Pattern) NextContext ¶
NextContext is Next with cancellation: the search aborts and returns ctx's error when the context is done, so an unbounded scan on a pathological pattern (e.g. an impossible bounded window) cannot pin a CPU indefinitely. The context is checked once per civil day, bounding a cancelled search to at most a single day's enumeration.
func (Pattern) PrevContext ¶
PrevContext is Prev with cancellation (see NextContext).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
isnow
command
Command isnow tests, derives, explains, schedules, and serves isnow (DTimpalr) date/time patterns.
|
Command isnow tests, derives, explains, schedules, and serves isnow (DTimpalr) date/time patterns. |
|
internal
|
|
|
app
Package app holds shared CLI runtime concerns: the injected environment and instant/zone parsing used across commands.
|
Package app holds shared CLI runtime concerns: the injected environment and instant/zone parsing used across commands. |
|
command
Package command wires the urfave/cli/v3 command tree over the domain logic.
|
Package command wires the urfave/cli/v3 command tree over the domain logic. |
|
constants
Package constants holds the CLI-layer sentinel errors.
|
Package constants holds the CLI-layer sentinel errors. |
|
domain
Package domain holds the pure command logic over the isnow library; it takes its clock and effects injected so every path is testable.
|
Package domain holds the pure command logic over the isnow library; it takes its clock and effects injected so every path is testable. |
|
server
Package server implements the isnow HTTP API (specs/contracts/http-api.md): a status-code membership test, occurrence derivation, a builder, long-poll, and SSE — every handler a pure function of (request, injected clock).
|
Package server implements the isnow HTTP API (specs/contracts/http-api.md): a status-code membership test, occurrence derivation, a builder, long-poll, and SSE — every handler a pure function of (request, injected clock). |