cron

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 6 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 cron expressions and finds the times they match in a timezone.

Expressions have five fields (minute, hour, day of month, month, day of week) with *, lists, ranges, steps and three-letter names, or one of the macros @yearly, @annually, @monthly, @weekly, @daily, @midnight and @hourly. As in Vixie cron, when both day fields are restricted (neither starts with *), a day matches if either matches.

Times are matched on the wall clock of the schedule's timezone. Across a daylight saving change, a time in the skipped hour fires at the first instant after the gap, and a time in the repeated hour fires once, at its first occurrence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadLocation

func LoadLocation(name string) (*time.Location, error)

LoadLocation loads an IANA timezone. Unlike time.LoadLocation it rejects "" and "Local", whose meaning depends on the server.

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. It rejects expressions that never match, such as February 30th.

func (Schedule) Next

func (s Schedule) Next(after time.Time, loc *time.Location) time.Time

Next returns the first time after the given one that the schedule matches in loc, or the zero time if there is none within eight years.

func (Schedule) Prev

func (s Schedule) Prev(at time.Time, loc *time.Location) time.Time

Prev returns the last time at or before the given one that the schedule matches in loc, or the zero time if there is none within eight years.

Jump to

Keyboard shortcuts

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