cron

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package cron parses and evaluates five-field cron expressions: minute, hour, day of month, month and day of week.

Index

Constants

This section is empty.

Variables

View Source
var ErrSyntax = errors.New("invalid cron expression")

ErrSyntax is wrapped by every error Parse returns.

Functions

This section is empty.

Types

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 such as "*/15 4-6 * * 1,3,5". Each field takes "*", numbers, ranges (a-b), lists (a,b,c) and steps (*/n, a-b/n, a/n). Sunday is 0 or 7.

func (Schedule) Last

func (s Schedule) Last(t time.Time, window time.Duration) time.Time

Last returns the latest time at or before t, within the given window, at which the schedule fires, or the zero time.

func (Schedule) Matches

func (s Schedule) Matches(t time.Time) bool

Matches reports whether the schedule fires in t's minute.

func (Schedule) Next

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

Next returns the first time after t at which the schedule fires, in t's zone, or the zero time if there is none within eight years, as for "0 0 30 2 *".

Jump to

Keyboard shortcuts

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