Documentation ¶
Overview ¶
Package schedule provides types to define time switch schedule intervals for outlets.
Index ¶
- type DayTime
- type Interval
- type Schedule
- func (s *Schedule) AddInterval(interval Interval) error
- func (s *Schedule) Contains(t time.Time) bool
- func (s *Schedule) DeleteInterval(interval Interval) error
- func (s *Schedule) Enabled() bool
- func (s *Schedule) MarshalJSON() ([]byte, error)
- func (s *Schedule) UnmarshalJSON(b []byte) error
- func (s *Schedule) UpdateInterval(interval Interval) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DayTime ¶
DayTime is a time definition that is agnostic of concrete dates and is only concerned about hours and minutes. This can be used to define a point in time that applies to any day of the week.
func NewDayTime ¶
NewDayTime create a new DayTime from an hour and minute.
type Interval ¶
type Interval struct { ID string `json:"id"` Enabled bool `json:"enabled"` Weekdays []time.Weekday `json:"weekdays"` From DayTime `json:"from"` To DayTime `json:"to"` }
Interval defines a time frame consisting of a start and end time and a list of weekdays for which the interval is valid.
type Schedule ¶
Schedule is a collection of intervals.
func NewWithIntervals ¶
NewWithIntervals create a new *Schedule with intervals.
func (*Schedule) AddInterval ¶
AddInterval adds an interval to the schedule of an outlet.
func (*Schedule) DeleteInterval ¶
DeleteInterval deletes an interval of the schedule of an outlet. Will return an error if the interval does not exist.
func (*Schedule) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
This hides that fact that *Schedule wraps a slice of Interval in the marshalled json.
func (*Schedule) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
This ensures that the json bytes are correctly unmarshalled into the internal slice of Interval values.
func (*Schedule) UpdateInterval ¶
UpdateInterval updates an interval of the schedule of an outlet. Will return an error if the interval does not exist.