cronspec

package
v0.261.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 4 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 cronspec is muster's ONE cron grammar: the five-field UTC expression a builtin officer's schedule (internal/officers/builtin) and a scheduled host job (internal/hostjobs, docs/host-jobs.md) both take, so the two cannot disagree about what an expression means. A leaf of the standard library alone, so the host binary (muster-mirror) checks its own jobs file with it without linking the server's stores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cron

type Cron struct {
	// contains filtered or unexported fields
}

Cron is a parsed five-field cron expression — minute hour day-of-month month day-of-week — evaluated in UTC. Each field takes `*`, a number, a range `a-b`, a list `a,b,c` and a step `*/n` or `a-b/n`; day-of-week is 0–6 with 0 (or 7) Sunday. When BOTH day fields are restricted a day matches if EITHER does; a field counts as unrestricted only when it is a bare `*` — so `*/2` restricts (robfig/cron's rule; Vixie cron treats any field starting with `*` as unrestricted). No names (MON, JAN), no `@daily` macros, no seconds: 0118's CHECK already holds an officer schedule's column to five fields, and 0166's a host job's.

func Parse

func Parse(expr string) (Cron, error)

Parse parses expr, refusing (naming the field) anything outside the grammar above.

func (Cron) Next

func (c Cron) Next(t time.Time) (time.Time, bool)

Next is the first minute strictly after t (in UTC) that c matches, and false when there is none within cronHorizon.

func (Cron) ShortestInterval

func (c Cron) ShortestInterval(from time.Time) time.Duration

ShortestInterval is the shortest gap between two consecutive fires of c in the eight days after from (0 when it fires at most once there): what a host officer's spawn budget is sized from (officers.SpawnBudgetFor).

Jump to

Keyboard shortcuts

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