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

cron

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cron parses five-field cron expressions and finds when they next fire. It has no clock and starts no goroutines: callers pass the time.

Fields are minute, hour, day of month, month and day of week. Each is a comma list of "*", "?", a value, a range a-b, optionally followed by "/step". Months and weekdays may be written as names (jan, mon). Day of week 7 means Sunday. When both day fields are restricted a day matches if either does (the traditional rule). The macros @yearly, @annually, @monthly, @weekly, @daily, @midnight and @hourly are accepted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ParseError

type ParseError struct {
	Field  string // "" when the expression as a whole is wrong
	Detail string
}

ParseError says which field of an expression is wrong and why.

func (*ParseError) Error

func (e *ParseError) Error() string

type Schedule

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

Schedule is a parsed expression.

func Parse

func Parse(expr string) (Schedule, error)

Parse reads an expression. Errors are *ParseError.

func (Schedule) Next

func (s Schedule) Next(after time.Time) time.Time

Next returns the first matching minute strictly after the given time, in its location, or the zero time if the expression never fires (Feb 30).

A time inside a spring-forward gap fires at the first moment after the gap that day; a repeated autumn hour fires once.

Jump to

Keyboard shortcuts

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