Documentation ¶
Overview ¶
Package twindow provides enums and functions to operate with resources related to Time Windows
Index ¶
- Constants
- func GetMinStartDate() time.Time
- func IsCalendarAlignedTimeUnit(timeUnit string) bool
- func IsRollingWindowTimeUnit(timeUnit string) bool
- func IsTimeUnit(timeUnit string) bool
- func ParseStartDate(startDateStr string) (time.Time, error)
- type CalendarTimeWindow
- func (timeWindow CalendarTimeWindow) GetStartTime() time.Time
- func (timeWindow CalendarTimeWindow) GetTimePeriod(timestamp time.Time) TimePeriod
- func (timeWindow CalendarTimeWindow) MarshalJSON() ([]byte, error)
- func (timeWindow CalendarTimeWindow) String() string
- func (timeWindow CalendarTimeWindow) Type() TimeWindowTypeEnum
- type Date
- type DateWithTime
- type RollingTimeWindow
- type TimeOfDay
- type TimePeriod
- type TimeUnitEnum
- type TimeWindow
- type TimeWindowTypeEnum
Constants ¶
const (
HoursInDay uint32 = 24
)
const ( // IsoDateTimeOnlyLayout is date and time only (without time zone) of iso layout IsoDateTimeOnlyLayout string = "2006-01-02 15:04:05" )
Variables ¶
This section is empty.
Functions ¶
func GetMinStartDate ¶
func IsRollingWindowTimeUnit ¶
func IsTimeUnit ¶
Types ¶
type CalendarTimeWindow ¶
type CalendarTimeWindow struct { TimeZone *time.Location DateWithTime DateWithTime // contains filtered or unexported fields }
func (CalendarTimeWindow) GetStartTime ¶
func (timeWindow CalendarTimeWindow) GetStartTime() time.Time
func (CalendarTimeWindow) GetTimePeriod ¶
func (timeWindow CalendarTimeWindow) GetTimePeriod(timestamp time.Time) TimePeriod
func (CalendarTimeWindow) MarshalJSON ¶
func (timeWindow CalendarTimeWindow) MarshalJSON() ([]byte, error)
func (CalendarTimeWindow) String ¶
func (timeWindow CalendarTimeWindow) String() string
func (CalendarTimeWindow) Type ¶
func (timeWindow CalendarTimeWindow) Type() TimeWindowTypeEnum
type DateWithTime ¶
DateWithTime represents day in calendar with time of day
type RollingTimeWindow ¶
type RollingTimeWindow struct {
// contains filtered or unexported fields
}
func (RollingTimeWindow) GetTimePeriod ¶
func (r RollingTimeWindow) GetTimePeriod(timestamp time.Time) TimePeriod
func (RollingTimeWindow) MarshalJSON ¶
func (r RollingTimeWindow) MarshalJSON() ([]byte, error)
func (RollingTimeWindow) String ¶
func (r RollingTimeWindow) String() string
func (RollingTimeWindow) Type ¶
func (r RollingTimeWindow) Type() TimeWindowTypeEnum
type TimeOfDay ¶
type TimeOfDay interface {
Clock() (hour, min, sec int)
}
TimeOfDay represents valid time of day
type TimePeriod ¶
TimePeriod represents a period in time with fixed start and end
func (TimePeriod) Duration ¶
func (tp TimePeriod) Duration() time.Duration
Duration returns duration from Start to End of TimePeriod
type TimeUnitEnum ¶
type TimeUnitEnum int16
TimeUnitEnum represents enum for time unit types
const ( Second TimeUnitEnum = iota + 1 Minute Hour Day Week Month Quarter Year )
Second is value of valid time units
func GetTimeUnitEnum ¶
func GetTimeUnitEnum(typ TimeWindowTypeEnum, timeUnit string) (timeUnitEnum TimeUnitEnum)
func MustParseTimeUnit ¶
func MustParseTimeUnit(timeUnit string) TimeUnitEnum
MustParseTimeUnit parses passed time unit
func (TimeUnitEnum) Duration ¶
func (tu TimeUnitEnum) Duration() time.Duration
Duration returns time.Duration value of fixed duration TimeUnitEnum
func (TimeUnitEnum) String ¶
func (tu TimeUnitEnum) String() string
type TimeWindow ¶
type TimeWindow interface { GetTimePeriod(t time.Time) TimePeriod String() string Type() TimeWindowTypeEnum MarshalJSON() ([]byte, error) }
TimeWindow is an algorithm that assigns a TimePeriod for every point in time
func NewCalendarTimeWindow ¶
func NewCalendarTimeWindow( unit TimeUnitEnum, count uint32, timeZone *time.Location, dateWithTime DateWithTime, ) (TimeWindow, error)
NewCalendarTimeWindow creates new calendar time window
func NewRollingTimeWindow ¶
func NewRollingTimeWindow(unit TimeUnitEnum, count uint32) (TimeWindow, error)
NewRollingTimeWindow creates new rolling time window
type TimeWindowTypeEnum ¶
type TimeWindowTypeEnum int16
TimeWindowTypeEnum represents enum for time window types
const ( Rolling TimeWindowTypeEnum = iota + 1 Calendar )
Rolling is value of valid time windows
func (TimeWindowTypeEnum) String ¶
func (s TimeWindowTypeEnum) String() string