timeinterval

package
v0.22.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: Apache-2.0 Imports: 8 Imported by: 15

Documentation

Index

Constants

View Source
const TimeLayout = "15:04"

TimeLayout specifies the layout to be used in time.Parse() calls for time intervals.

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 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"`
}

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-seperated 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