Documentation ¶
Index ¶
- Constants
- type TimeRange
- func NewDomTimeRange(left, right uint) (*TimeRange, error)
- func NewDowTimeRange(left, right uint) (*TimeRange, error)
- func NewHourTimeRange(left, right uint) (*TimeRange, error)
- func NewMinTimeRange(left, right uint) (*TimeRange, error)
- func NewMonthTimeRange(left, right uint) (*TimeRange, error)
- func NewTimeRange(spec string) (*TimeRange, error)
- type TimeSpan
- func (t *TimeSpan) Clock() (bool, time.Time)
- func (t *TimeSpan) ClockIn(tm time.Time) (bool, time.Time)
- func (t *TimeSpan) Interval() time.Duration
- func (t *TimeSpan) IsTimeUp(tm time.Time) (bool, time.Time)
- func (t *TimeSpan) IsTimeUpNow() (bool, time.Time)
- func (t *TimeSpan) LastAt() time.Time
- func (t *TimeSpan) ResetAs(tm time.Time)
- func (t *TimeSpan) ResetNow()
- type Timer
- type TimerList
Constants ¶
const (
// AnyTimeCronSpec 是任何时候都符合的 cronspec
AnyTimeCronSpec = "* * * * *"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TimeRange ¶
type TimeRange struct {
// contains filtered or unexported fields
}
TimeRange 描述一个时间范围, 并判断 time 是否符合 range. TimeRange 的判断条件来自于 Cron format, 见 https://en.wikipedia.org/wiki/Cron
Ex:
NewHourTimeRange(1,18), 表明 1-18 点都是符合(包括 18:59 也是)
Note:
TimeRange 中都是 [left,right] 的
func NewDomTimeRange ¶
NewDomTimeRange is same as 'NewTimeRange("* * * left-right *")'
func NewDowTimeRange ¶
NewDowTimeRange is same as 'NewTimeRange("* * * * left-right")'
func NewHourTimeRange ¶
NewHourTimeRange is same as 'NewTimeRange("* left-right * * *")'
func NewMinTimeRange ¶
NewMinTimeRange is same as 'NewTimeRange("left-right * * * *")'
func NewMonthTimeRange ¶
NewMonthTimeRange is same as 'NewTimeRange("* * * left-right *")'
func NewTimeRange ¶
NewTimeRange 从 cron spec 创建 TimeRange, 每一必须为 left-right 或 *
┌───────────── minute (0 - 59) │ ┌───────────── hour (0 - 23) │ │ ┌───────────── day of the month (1 - 31) │ │ │ ┌───────────── month (1 - 12) │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday; │ │ │ │ │ 7 is also Sunday on some systems) │ │ │ │ │ │ │ │ │ │ * * * * *
type TimeSpan ¶
type TimeSpan struct {
// contains filtered or unexported fields
}
func (*TimeSpan) IsTimeUpNow ¶
IsTimeUpNow 与 now_ts 比较
type Timer ¶
type Timer interface { // Clock 检查当前时间是否允许, 允许情况下会执行需要的置位(TimeSpan) Clock() (bool, time.Time) // Clock 检查指定时间是否允许, 允许情况下会执行需要的置位(TimeSpan) ClockIn(tm time.Time) (bool, time.Time) // IsTimeUpNow 检查指定时间是否允许 IsTimeUpNow() (bool, time.Time) // IsTimeUp 检查指定时间是否允许 IsTimeUp(tm time.Time) (bool, time.Time) }
type TimerList ¶
type TimerList struct {
// contains filtered or unexported fields
}
TimerList 用于检测多个 Timer 是否同时 time up
Note: next 会有误差, 因为只是取的 timer 中 next 最大值