timeinterval

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 10 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DayOfMonthRange

type DayOfMonthRange struct {
	InclusiveRange
}

A DayOfMonthRange is an inclusive range that may have negative Beginning/End values that represent distance from the End of the month Beginning at -1.

func (*DayOfMonthRange) UnmarshalJSON

func (r *DayOfMonthRange) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for DayOfMonthRange. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*DayOfMonthRange) UnmarshalYAML

func (r *DayOfMonthRange) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for DayOfMonthRange.

type InclusiveRange

type InclusiveRange struct {
	Begin int
	End   int
}

InclusiveRange is used to hold the Beginning and End values of many time interval components.

func (InclusiveRange) MarshalText

func (ir InclusiveRange) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for InclusiveRange. It converts the struct into a colon-separated string, or a single element if appropriate. e.g. "monday:friday" or "monday"

func (InclusiveRange) MarshalYAML

func (ir InclusiveRange) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for InclusiveRange.

type Intervener added in v0.27.0

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

Intervener determines whether a given time and active route time interval should mute outgoing notifications. It implements the TimeMuter interface.

func NewIntervener added in v0.27.0

func NewIntervener(ti map[string][]TimeInterval) *Intervener

func (*Intervener) Mutes added in v0.27.0

func (i *Intervener) Mutes(names []string, now time.Time) (bool, error)

type Location added in v0.25.0

type Location struct {
	*time.Location
}

A Location is a container for a time.Location, used for custom unmarshalling/validation logic.

func (Location) MarshalJSON added in v0.25.0

func (tz Location) MarshalJSON() (out []byte, err error)

MarshalJSON implements the json.Marshaler interface for Location.

func (Location) MarshalText added in v0.25.0

func (tz Location) MarshalText() ([]byte, error)

MarshalText implements the econding.TextMarshaler interface for Location. It marshals a Location back into a string that represents a time.Location.

func (Location) MarshalYAML added in v0.25.0

func (tz Location) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for Location.

func (*Location) UnmarshalJSON added in v0.25.0

func (tz *Location) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Location. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*Location) UnmarshalYAML added in v0.25.0

func (tz *Location) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for Location.

type MonthRange

type MonthRange struct {
	InclusiveRange
}

A MonthRange is an inclusive range between [1, 12] where 1 = January.

func (*MonthRange) UnmarshalJSON

func (r *MonthRange) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for MonthRange. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*MonthRange) UnmarshalYAML

func (r *MonthRange) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for MonthRange.

type TimeInterval

type TimeInterval struct {
	Times       []TimeRange       `yaml:"times,omitempty" json:"times,omitempty"`
	Weekdays    []WeekdayRange    `yaml:"weekdays,flow,omitempty" json:"weekdays,omitempty"`
	DaysOfMonth []DayOfMonthRange `yaml:"days_of_month,flow,omitempty" json:"days_of_month,omitempty"`
	Months      []MonthRange      `yaml:"months,flow,omitempty" json:"months,omitempty"`
	Years       []YearRange       `yaml:"years,flow,omitempty" json:"years,omitempty"`
	Location    *Location         `yaml:"location,flow,omitempty" json:"location,omitempty"`
}

TimeInterval describes intervals of time. ContainsTime will tell you if a golang time is contained within the interval.

func (TimeInterval) ContainsTime

func (tp TimeInterval) ContainsTime(t time.Time) bool

ContainsTime returns true if the TimeInterval contains the given time, otherwise returns false.

type TimeRange

type TimeRange struct {
	StartMinute int
	EndMinute   int
}

TimeRange represents a range of minutes within a 1440 minute day, exclusive of the End minute. A day consists of 1440 minutes. For example, 4:00PM to End of the day would Begin at 1020 and End at 1440.

func (TimeRange) MarshalJSON

func (tr TimeRange) MarshalJSON() (out []byte, err error)

MarshalJSON implements the json.Marshaler interface for TimeRange.

func (TimeRange) MarshalYAML

func (tr TimeRange) MarshalYAML() (out interface{}, err error)

MarshalYAML implements the yaml.Marshaler interface for TimeRange.

func (*TimeRange) UnmarshalJSON

func (tr *TimeRange) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Timerange. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*TimeRange) UnmarshalYAML

func (tr *TimeRange) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for TimeRanges.

type WeekdayRange

type WeekdayRange struct {
	InclusiveRange
}

A WeekdayRange is an inclusive range between [0, 6] where 0 = Sunday.

func (WeekdayRange) MarshalText

func (r WeekdayRange) MarshalText() ([]byte, error)

MarshalText implements the econding.TextMarshaler interface for WeekdayRange. It converts the range into a colon-separated string, or a single weekday if possible. e.g. "monday:friday" or "saturday".

func (WeekdayRange) MarshalYAML

func (r WeekdayRange) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for WeekdayRange.

func (*WeekdayRange) UnmarshalJSON

func (r *WeekdayRange) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for WeekdayRange. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*WeekdayRange) UnmarshalYAML

func (r *WeekdayRange) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for WeekdayRange.

type YearRange

type YearRange struct {
	InclusiveRange
}

A YearRange is a positive inclusive range.

func (*YearRange) UnmarshalJSON

func (r *YearRange) UnmarshalJSON(in []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for YearRange. It delegates to the YAML unmarshaller as it can parse JSON and has validation logic.

func (*YearRange) UnmarshalYAML

func (r *YearRange) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the Unmarshaller interface for YearRange.

Jump to

Keyboard shortcuts

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