timeinterval

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 10 Imported by: 3

Documentation

Overview

Package timeinterval is time range data structure ,many trade system has this. code inspired by Altermanager

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) UnmarshalText

func (dr *DayOfMonthRange) UnmarshalText(in []byte) error

type InclusiveRange

type InclusiveRange struct {
	Begin int
	End   int
}

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

type Location

type Location struct {
	*time.Location
}

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

func (*Location) UnmarshalText

func (tz *Location) UnmarshalText(str []byte) error

type MonthRange

type MonthRange struct {
	InclusiveRange
}

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

func (*MonthRange) UnmarshalText

func (mr *MonthRange) UnmarshalText(in []byte) error

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:"daysOfMonth,flow,omitempty" json:"daysOfMonth,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"`
}

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) UnmarshalText

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

type WeekdayRange

type WeekdayRange struct {
	InclusiveRange
}

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

func (*WeekdayRange) UnmarshalText

func (wr *WeekdayRange) UnmarshalText(in []byte) error

type YearRange

type YearRange struct {
	InclusiveRange
}

A YearRange is a positive inclusive range.

func (*YearRange) UnmarshalText

func (yr *YearRange) UnmarshalText(in []byte) error

Jump to

Keyboard shortcuts

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