schedule

package
v3.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAllowed = errors.New("not allowed")
	ErrExcluded   = errors.New("excluded")
	ErrInvalid    = errors.New("invalid expression")
	ErrImpossible = errors.New("impossible schedule")
	ErrDrift      = errors.New("drift")
	ErrNextDay    = errors.New("next day")

	SchedFmt    = "%s: %s"
	AllMonths   = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
	AllWeekdays = []int{1, 2, 3, 4, 5, 6, 7}
	AllDays     = []day{
		{/* contains filtered or unexported fields */},
		{/* contains filtered or unexported fields */},
		{/* contains filtered or unexported fields */},
		{/* contains filtered or unexported fields */},
		{/* contains filtered or unexported fields */},
		{/* contains filtered or unexported fields */},
		{/* contains filtered or unexported fields */},
	}
	CalendarNames = map[string]int{
		"jan":       1,
		"feb":       2,
		"mar":       3,
		"apr":       4,
		"may":       5,
		"jun":       6,
		"jul":       7,
		"aug":       8,
		"sep":       9,
		"oct":       10,
		"nov":       11,
		"dec":       12,
		"january":   1,
		"february":  2,
		"march":     3,
		"april":     4,
		"june":      6,
		"july":      7,
		"august":    8,
		"september": 9,
		"october":   10,
		"november":  11,
		"december":  12,
		"mon":       1,
		"tue":       2,
		"wed":       3,
		"thu":       4,
		"fri":       5,
		"sat":       6,
		"sun":       7,
		"monday":    1,
		"tuesday":   2,
		"wednesday": 3,
		"thursday":  4,
		"friday":    5,
		"saturday":  6,
		"sunday":    7,
	}
)

Functions

func ISOWeekday

func ISOWeekday(tm time.Time) int

ISOWeekday is like (time.Time).Weekday, but sunday is 7 instead of 0

func NextWithLast

func NextWithLast(tm time.Time) funcopt.O

func NextWithTime

func NextWithTime(tm time.Time) funcopt.O

Types

type Expr

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

func New

func New(s string) *Expr

func (*Expr) Append

func (t *Expr) Append(s string) error

func (*Expr) AppendExprDataset

func (t *Expr) AppendExprDataset(ds Schedules)

func (*Expr) Dataset

func (t *Expr) Dataset() Schedules

func (*Expr) Next

func (t *Expr) Next(opts ...funcopt.O) (time.Time, time.Duration, error)

Next returns the next time the expression is valid, and the duration after that time the schedule is denied.

func (Expr) String

func (t Expr) String() string

func (*Expr) Test

func (t *Expr) Test(tm time.Time) (time.Duration, error)

func (*Expr) TestWithLast

func (t *Expr) TestWithLast(tm time.Time, last time.Time) (time.Duration, error)

type Schedule

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

Schedule is a single parsed scheduling expression

func (Schedule) GetTimerange

func (t Schedule) GetTimerange(tm, last time.Time) (time.Time, time.Duration, error)

func (Schedule) IsInDays

func (t Schedule) IsInDays(tm time.Time) bool

func (Schedule) IsInMonths

func (t Schedule) IsInMonths(tm time.Time) bool

func (Schedule) IsInWeeks

func (t Schedule) IsInWeeks(tm time.Time) bool

func (Schedule) TestIsInDays

func (t Schedule) TestIsInDays(tm time.Time) error

func (Schedule) TestIsInMonths

func (t Schedule) TestIsInMonths(tm time.Time) error

func (Schedule) TestIsInWeeks

func (t Schedule) TestIsInWeeks(tm time.Time) error

type Schedules

type Schedules []Schedule

Schedules is a list of Schedule, applying a union logic to allowed ranges

func (Schedules) Excludes

func (t Schedules) Excludes() Schedules

Excludes returns the filtered elements with .Exclude=true

func (Schedules) Includes

func (t Schedules) Includes() Schedules

Includes returns the filtered elements with .Exclude=false

Jump to

Keyboard shortcuts

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