schedparse

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package schedparse is a small client-side natural-language → trigger compiler for the mecatui /schedule overlay's Create form.

It is a small pattern table for common scheduling phrases, NOT a full NLP engine: a handful of ordered regexes, first-match-wins. A phrase that does not match any pattern returns ok=false, and the caller falls back to treating the input verbatim as a raw cron expression.

The package is stdlib-only (regexp + time) and depends on nothing in engine/ or internal/ — it is a pure leaf that runs client-side.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Cron    string    // a 5-field cron expression, set when the phrase is recurring
	OneShot time.Time // a wall-clock instant, set when the phrase is a one-shot (zero otherwise)
}

Result is the outcome of Compile: exactly one of Cron or OneShot is set. The caller decides which kind of trigger to build (a cron schedule vs a one-shot schedule) — Compile only produces the value.

func Compile

func Compile(nl string, now time.Time) (Result, bool)

Compile parses a natural-language scheduling phrase into a trigger result. If the phrase matches a known pattern, exactly one of Cron or OneShot is set and ok is true. If no pattern matches, ok is false and the caller should treat the input verbatim as a raw cron expression.

now is the reference instant for the one-shot patterns ("next monday 9am", "in 30 minutes", "tomorrow at noon"); it is ignored by the recurring (cron) patterns.

Jump to

Keyboard shortcuts

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