Documentation
¶
Overview ¶
Package engine implements the isnow pattern engine: recognition of pattern source via the grammar repo's ANTLR-generated parser, the shorthand-ladder role assignment, compilation of every field term to a predicate, membership (Holds) over a broken-down instant, and occurrence derivation (Next/Prev) under the 100-year search horizon.
The root go-isnow package is a thin facade over this package: everything exported here is re-exported there unchanged, so external callers never import the engine directly. Errors are the internal/constants sentinels, matchable with errors.Is.
Index ¶
- func Code(err error) string
- func Is(src PatternText, 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
- type PatternText
Constants ¶
This section is empty.
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 ¶
func Parse(src PatternText) (Pattern, error)
Parse recognizes src, resolves symbols and the shorthand ladder, and validates field domains. It returns one of constants.ErrSyntax, constants.ErrSymbol, constants.ErrRange, or constants.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).
type PatternText ¶
type PatternText string
PatternText is isnow pattern source text accepted by Parse. It is exported so callers in other packages can convert their string input at the call site.