cron

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 5 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 cron parses standard five-field cron expressions and computes their next run times.

An expression has five fields separated by spaces: minute (0-59), hour (0-23), day of month (1-31), month (1-12 or JAN-DEC), and day of week (0-7 or SUN-SAT, where both 0 and 7 mean Sunday). Each field is "*", a value, a range "a-b", or a list of those separated by commas, and any of them may carry a step "/n". When both day fields are restricted, a day matches if either matches, as in classic cron. The macros @yearly, @annually, @monthly, @weekly, @daily, @midnight, and @hourly are also accepted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Schedule

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

Schedule is a parsed cron expression.

func Parse

func Parse(expr string) (*Schedule, error)

Parse parses a cron expression.

func (*Schedule) Next

func (s *Schedule) Next(t time.Time) (time.Time, error)

Next returns the first time after t that the schedule matches, in t's location. It fails if the schedule never matches, such as on February 31.

The schedule is matched against the wall clock, so daylight saving time behaves as in classic cron: a time skipped when clocks go forward runs right after the jump, and a time repeated when clocks go back runs once.

Jump to

Keyboard shortcuts

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