cron

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 5 Imported by: 0

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