cron

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 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 five-field cron expressions and computes their schedule, in UTC or in a time zone.

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 "minute hour day-of-month month day-of-week" (each field: *, a number, a range a-b, a list, and /step; month and weekday names work) or one of @hourly, @daily, @weekly, @monthly, @yearly. As in classic cron, when both day fields are restricted a time matches if either does.

func (*Schedule) In added in v0.8.0

func (s *Schedule) In(loc *time.Location) *Schedule

In returns the schedule read in loc: its fields are wall-clock times there.

Daylight saving follows the usual cron rules. When the clocks go forward, a time that doesn't exist that day runs once, right after the gap. When they go back, a schedule with fixed hours runs once for a repeated time, at its first occurrence; one that matches every hour runs throughout.

func (*Schedule) Prev

func (s *Schedule) Prev(t time.Time) (time.Time, bool)

Prev returns the latest scheduled time at or before t (minute resolution), or false if none exists within about eight years back.

Jump to

Keyboard shortcuts

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