timeRangeLib

package
v0.0.24-beta-4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const CRON = cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow

Variables

View Source
var AllowedFrequencies = []Frequency{Fixed, Daily, Weekly, WeeklyRange, Monthly}

Functions

This section is empty.

Types

type BaseTimeRangeExpressionEvaluator

type BaseTimeRangeExpressionEvaluator struct {
	TimeRange  TimeRange
	TargetTime time.Time
	// contains filtered or unexported fields
}

type DailyTimeRangeExpressionEvaluator

type DailyTimeRangeExpressionEvaluator struct {
	BaseTimeRangeExpressionEvaluator
}

type ErrorMessage

type ErrorMessage string
const (
	InvalidFrequencyType                 ErrorMessage = "invalid Frequency type"
	HourMinuteNotPresent                 ErrorMessage = "hourMinuteFrom and hourMinuteTo must be present for Daily frequency"
	TimeFromOrToNotPresent               ErrorMessage = "timeFrom and timeTo must be present for Fixed frequency"
	TimeFromLessThanTimeTo               ErrorMessage = "timeFrom must be less than timeTo for Fixed frequency"
	TimeFromEqualToTimeTo                ErrorMessage = "timeFrom must not be equal to timeTo for Fixed frequency"
	WeekDayOutsideRange                  ErrorMessage = "one or both of the values are outside the range of 0 to 6"
	WeekDaysNotPresent                   ErrorMessage = "weekdays, must be present for Weekly frequency"
	WeekDayFromOrToNotPresent            ErrorMessage = "weekdayFrom, must be present for WeeklyRange frequency"
	DayFromOrToNotPresent                ErrorMessage = "dayFrom, dayTo, must be present for Monthly frequency"
	ToBeforeFrom                         ErrorMessage = "Invalid value of hourMinuteFrom or hourMinuteTo  for same day ,hourMinuteFrom >hourMinuteTo"
	BothLessThanZeroAndFromGreaterThanTo ErrorMessage = "invalid value of DayFrom or DayTo,DayFrom and DayTo is less than zero and  dayFrom > dayTo"
	DayFromOrToNotValid                  ErrorMessage = "invalid value of dayFrom or dayTo"
)

type Frequency

type Frequency string
const (
	Fixed       Frequency = "Fixed"
	Daily       Frequency = "Daily"
	Weekly      Frequency = "Weekly"
	WeeklyRange Frequency = "WeeklyRange"
	Monthly     Frequency = "Monthly"
)

type MonthlyTimeRangeExpressionEvaluator

type MonthlyTimeRangeExpressionEvaluator struct {
	BaseTimeRangeExpressionEvaluator
}

type TimeRange

type TimeRange struct {
	TimeFrom       time.Time
	TimeTo         time.Time
	HourMinuteFrom string
	HourMinuteTo   string
	DayFrom        int
	DayTo          int
	WeekdayFrom    time.Weekday
	WeekdayTo      time.Weekday
	Weekdays       []time.Weekday
	Frequency      Frequency
}

func (TimeRange) GetTimeRangeWindow

func (tr TimeRange) GetTimeRangeWindow(targetTime time.Time) (nextWindowEdge time.Time, isTimeBetween bool, err error)

func (TimeRange) ValidateTimeRange

func (tr TimeRange) ValidateTimeRange() error

type WeeklyRangeTimeRangeExpressionEvaluator

type WeeklyRangeTimeRangeExpressionEvaluator struct {
	BaseTimeRangeExpressionEvaluator
}

type WeeklyTimeRangeExpressionEvaluator

type WeeklyTimeRangeExpressionEvaluator struct {
	BaseTimeRangeExpressionEvaluator
}

Jump to

Keyboard shortcuts

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