Documentation
¶
Index ¶
- Constants
- Variables
- func BuildVersion() string
- func NewIterator(nexter Nexter, cfg Config) (iter.Seq[time.Time], error)
- func ParseStartTime(s, layout string, loc *time.Location, explicitTZ bool, fallback time.Time) (time.Time, error)
- func ParseTimeOrDefault(s, layout string, loc *time.Location, fallback time.Time) (time.Time, error)
- func ResolveFormat(format string) string
- func ResolveLocation(name string) (*time.Location, error)
- type Config
- type ExpandParams
- type NextFunc
- type Nexter
- type PreparedExpand
Constants ¶
const DefaultVersion = "(devel)"
DefaultVersion is the fallback version string when build info is unavailable.
Variables ¶
var ErrIteratorConfig = errors.New("IteratorConfig")
ErrIteratorConfig indicates an invalid iterator configuration.
Functions ¶
func BuildVersion ¶
func BuildVersion() string
BuildVersion returns the main module version from Go build info, or DefaultVersion.
func NewIterator ¶
NewIterator returns a reusable, stateless iterator yielding firing times from cfg.Start until the configured stop condition is reached.
func ParseStartTime ¶
func ParseStartTime(s, layout string, loc *time.Location, explicitTZ bool, fallback time.Time) (time.Time, error)
ParseStartTime parses s in layout and loc, normalizing the resulting timestamp into loc when explicitTZ is true so cron evaluation uses the requested timezone even if s includes an offset.
func ParseTimeOrDefault ¶
func ParseTimeOrDefault(s, layout string, loc *time.Location, fallback time.Time) (time.Time, error)
ParseTimeOrDefault parses s in layout and loc, returning fallback when s is empty.
func ResolveFormat ¶
ResolveFormat expands named layout presets (datetime, date, time, rfc3339, rfc3339nano) and otherwise returns format verbatim as a Go time layout.
Types ¶
type Config ¶
type Config struct {
Start time.Time
Count int // negative value is ignored
Duration time.Duration // negative value is ignored
End time.Time
Inclusive bool
}
Config configures the firing-time iterator. Start is required, and at least one stop condition must be specified: Count >= 0, Duration >= 0, or a non-zero End. By default firing times are strictly after Start; set Inclusive to include Start when it matches.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with unset Count and Duration.
type ExpandParams ¶
type ExpandParams struct {
Expr string
Start string
End string
Count int // negative value is ignored
Duration time.Duration // negative value is ignored
Format string
Timezone string
Seconds bool
Inclusive bool
}
ExpandParams holds common expansion parameters shared by CLI and MCP adapters.
type Nexter ¶
type Nexter interface {
// Next returns the next firing time strictly after t, or the zero Time if none exists.
Next(t time.Time) time.Time
}
Nexter computes the next firing time after a given timestamp.
func NewNexterWithSeconds ¶
NewNexterWithSeconds parses a 6-field cron expression (with leading seconds) or descriptor.
type PreparedExpand ¶
PreparedExpand holds the validated iterator and resolved formatting/location settings.
func PrepareExpand ¶
func PrepareExpand(params ExpandParams, now func() time.Time) (PreparedExpand, error)
PrepareExpand resolves timezone, layout, timestamps, and cron expression into a ready-to-run iterator.