Documentation
¶
Overview ¶
Package schedule provides support for scheduling events based on dates and times.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionSpec ¶
type ActionSpec[T any] struct { Name string Due datetime.TimeOfDay Dynamic DynamicTimeOfDaySpec Repeat RepeatSpec T T }
ActionSpec represents a specification of an action to be taken at specific times of that day. The specification may refer to a dynamically evaluated time of day (eg. sunrise/sunset) with an offset. In addition it may specify a repeat interval and an optional number of times for the action to be repeated.
func (ActionSpec[T]) Evaluate ¶
func (a ActionSpec[T]) Evaluate(cd datetime.CalendarDate, place datetime.Place) ActionSpec[T]
Evaluate returns a new ActionSpec with the Due field set to the result of evaluating the DynamicDue field if it is non-nil (with the DynamicOffset applied).
type ActionSpecs ¶
type ActionSpecs[T any] []ActionSpec[T]
func (ActionSpecs[T]) Evaluate ¶
func (a ActionSpecs[T]) Evaluate(cd datetime.CalendarDate, place datetime.Place) ActionSpecs[T]
Evaluate returns a new ActionSpecs with each of the ActionSpecs evaluated, that is, with any Dynamic functions evaluated and the results stored in the Due field. The returned ActionSpecs have their Dynamic fields zeroed out.
func (ActionSpecs[T]) SortStable ¶
func (a ActionSpecs[T]) SortStable()
Sort by due time, but preserve the order of actions with the same due time.
type Active ¶
Active represents the next scheduled action, ie. the one to be 'active' at time 'When'.
type AnnualScheduler ¶
type AnnualScheduler[T any] struct { // contains filtered or unexported fields }
AnnualScheduler provides a way to iterate over the specified actions for a single year.
func NewAnnualScheduler ¶
func NewAnnualScheduler[T any](actions ActionSpecs[T]) *AnnualScheduler[T]
NewAnnualScheduler returns a new annual scheduler with the supplied schedule.
func (*AnnualScheduler[T]) Scheduled ¶
func (s *AnnualScheduler[T]) Scheduled(yp datetime.YearPlace, dates Dates, bounds datetime.DateRange) iter.Seq[Scheduled[T]]
Scheduled returns an iterator over the scheduled actions for the given year and place that returns all of the scheduled actions for each day that has scheduled Actions. It will evaluate any dynamic due times and sort the actions by their evaluated due time.
type Dates ¶
type Dates struct {
Months datetime.MonthList // Whole months to include.
MirrorMonths bool // Include the 'mirror' months of those in For.
Ranges datetime.DateRangeList // Include specific date ranges.
Dynamic datetime.DynamicDateRangeList // Functions to generate dates that vary by year, such as solstices, seasons or holidays.
Constraints datetime.Constraints // Constraints to be applied, such as weekdays/weekends etc.
}
Dates represents a set of dates expressed as a combination of months, date ranges and constraints on those dates (eg. weekdays in March).
func (Dates) EvaluateDateRanges ¶
EvaluateDateRanges returns the list of date ranges that are represented by the totality of the information represented by Dates instance, including the evaluation of dynamic date ranges. The result is bounded by supplied bounds date range.
type DynamicTimeOfDaySpec ¶
type DynamicTimeOfDaySpec struct {
Due datetime.DynamicTimeOfDay
Offset time.Duration
}
DynamicTimeOfDaySpec represents a time of day that is dynamically evaluated and offset with a fixed duration.
type RepeatSpec ¶
RepeatSpec represents a repeat interval and an optional number of times for an action to be repeated.
type Scheduled ¶
type Scheduled[T any] struct { Date datetime.CalendarDate Specs ActionSpecs[T] }
Scheduled specifies the set of actions scheduled for a given date.