timer

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

View Source
var ErrNoNextOccurrence = errors.New("timer has no further occurrence")

Functions

func Next

func Next(kind Kind, value string, from time.Time, loc *time.Location) (time.Time, error)

Next returns the first due time of a timer definition after from. A cycle is either a Quartz cron expression or an ISO 8601 repeating interval R[n]/<duration>.

func NextNotBefore

func NextNotBefore(kind Kind, value string, from, earliest time.Time, loc *time.Location) (due time.Time, limited bool, err error)

NextNotBefore is Next for a timer that must not be due before earliest (MIN_TIMER_DURATION). A duration or repeating interval due earlier is due at earliest, a cron expression at its first time at or after earliest; a date is never moved. limited reports a moved due time.

func NextScheduled

func NextScheduled(schedule cron.Schedule, from, earliest time.Time) time.Time

NextScheduled returns the first start of a schedule after from and not before earliest (MIN_TIMER_DURATION): a cron at its first time at or after earliest, @every at earliest. Zero if there is none.

func ParseDate

func ParseDate(value string, loc *time.Location) (time.Time, error)

ParseDate parses an ISO 8601 date-time; values without offset are read in loc.

func ParseSchedule

func ParseSchedule(expr string, loc *time.Location) (cron.Schedule, error)

ParseSchedule parses a cron of a time schedule in loc.

func Validate

func Validate(kind Kind, value string) error

Validate checks a literal timer value without computing a due time.

Types

type CronSchedule

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

CronSchedule is a Quartz cron expression with 6 or 7 fields: seconds minutes hours day-of-month month day-of-week [year].

func ParseCron

func ParseCron(expr string, loc *time.Location) (*CronSchedule, error)

ParseCron translates the Quartz dialect into robfig/cron: Quartz counts day-of-week from 1 (Sunday) to 7, robfig from 0 (Sunday) to 6. L, W and # are not supported.

func (*CronSchedule) Next

func (this *CronSchedule) Next(from time.Time) (time.Time, error)

type Duration

type Duration struct {
	Years, Months, Weeks, Days int
	Clock                      time.Duration
}

Duration is an ISO 8601 duration. Years, months, weeks and days are calendar units, hours, minutes and seconds are fixed. Implementation follows ISO 8601-1:2019 section 5.5.2.4 (format with designators).

func ParseDuration

func ParseDuration(value string) (result Duration, err error)

func (Duration) AddTo

func (this Duration) AddTo(t time.Time) time.Time

func (Duration) IsZero

func (this Duration) IsZero() bool

type Kind

type Kind string
const (
	KindDuration Kind = "duration"
	KindDate     Kind = "date"
	KindCycle    Kind = "cycle"
)

Jump to

Keyboard shortcuts

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