Help us shape the future of Go! Take the 2026 Go Developer Survey

cron

package
v0.18.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cron parses 5-field cron expressions in an IANA time zone and computes their next slot under one daylight-saving rule, for every funcd consumer of a cron schedule (ADR-0211). It imports the standard library and api/fault only, and not time/tzdata: a program that needs zones without host files imports that itself.

Index

Constants

View Source
const Grammar = "a cron expression: 5 fields (minute hour day-of-month month day-of-week) of *, n, a-b, */s or " +
	"a-b/s in comma lists, or @yearly, @annually, @monthly, @weekly, @daily, @midnight or @hourly"

Grammar describes the accepted expressions in words; every parse error quotes it.

Variables

This section is empty.

Functions

func LoadZone

func LoadZone(name string) (*time.Location, error)

LoadZone resolves an IANA name: "" ⇒ time.UTC; "Local" or an unknown name ⇒ fault.Invalid naming it.

Types

type Timetable

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

Timetable is a parsed expression in a zone (Decision 1). Immutable and safe for concurrent use.

func Parse

func Parse(expr string, loc *time.Location) (*Timetable, error)

Parse parses expr in loc (nil ⇒ UTC): fault.Invalid naming expr, the failing field and Grammar, also when the expression matches no calendar date.

func (*Timetable) Next

func (t *Timetable) Next(after time.Time) time.Time

Next returns the earliest slot instant strictly after after (Decision 3). It never returns the zero Time for a Timetable from Parse.

A slot maps to the first instant whose local time is not earlier than the slot: the slot itself, its first occurrence in a fold, the end of the gap in a gap. That map never decreases with the slot, and a slot no later than after's local time maps to no later than after, so the answer is the first later slot whose instant is after after.

Jump to

Keyboard shortcuts

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