Documentation
¶
Overview ¶
Package recur describes when an automation runs: once, at a fixed interval, or at a local time of day on chosen weekdays in an IANA time zone. It validates requests, computes occurrences (including across daylight-saving transitions) and describes schedules for people.
Index ¶
Constants ¶
const ( KindOnce = "once" KindInterval = "interval" KindCalendar = "calendar" )
Rule kinds.
const MinInterval = time.Minute
MinInterval is the shortest delay or interval.
Variables ¶
This section is empty.
Functions ¶
func FormatLocal ¶
FormatLocal renders an instant for people and agents with its weekday, zone abbreviation and UTC offset, e.g. "Mon 2026-10-13 09:00 AEDT (+11:00)".
Types ¶
type Request ¶
type Request struct {
// In is a delay from now, e.g. "20m".
In string `json:"in,omitempty"`
// At is a moment: RFC 3339 with an offset, or local wall-clock time
// "2006-01-02T15:04" in Timezone.
At string `json:"at,omitempty"`
// Every is a fixed interval of elapsed time, at least MinInterval.
Every string `json:"every,omitempty"`
// Time is a local wall-clock time "15:04" repeated on Days in Timezone.
Time string `json:"time,omitempty"`
// Days are three-letter weekdays (mon..sun), "weekdays" or "weekends";
// empty means every day.
Days []string `json:"days,omitempty"`
// Timezone is an IANA name; empty means the seat's time zone.
Timezone string `json:"timezone,omitempty"`
}
Request is how an agent asks for a schedule. Exactly one of In, At, Every or Time is set; Days and Timezone qualify Time (and Timezone a local At).
type Rule ¶
type Rule struct {
Kind string `json:"kind"`
// At is the one-off moment (once).
At time.Time `json:"at,omitzero"`
// Every and Anchor define an interval: runs at Anchor + n*Every.
Every string `json:"every,omitempty"`
Anchor time.Time `json:"anchor,omitzero"`
// Time and Days define a calendar rule in Timezone.
Time string `json:"time,omitempty"`
Days []string `json:"days,omitempty"`
Timezone string `json:"timezone"`
}
Rule is a validated, stored schedule.
func Parse ¶
Parse validates a request. defaultTZ applies when the request names no time zone; now anchors "in" and "every".
func (Rule) CountBetween ¶
CountBetween counts occurrences in (from, to], up to limit.
func (Rule) Next ¶
Next returns the first occurrence strictly after t; ok is false when there is none.
func (Rule) Occurrences ¶
Occurrences lists up to n occurrences strictly after t.