schedule

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DailyRange

type DailyRange struct {
	StartTime time.Duration
	EndTime   time.Duration
}

DailyRange represents a daily schedule.

func NewDailyRange

func NewDailyRange(startTime, endTime string) (*DailyRange, error)

NewDailyRange returns a DailyRange with the given range. If endTime < startTime, it treats the endTime as the next day. For example, if startTime=23:00:00 and endTime=01:00:00 are given, endTime will be 25:00:00.

func (*DailyRange) IsActive

func (d *DailyRange) IsActive(t time.Time) bool

IsActive returns true if t is in the range. This function depends on the timezone of t.

func (*DailyRange) NextEdge

func (d *DailyRange) NextEdge(now time.Time) time.Time

NextEdge returns the earlier of the next StartTime or EndTime.

type Range

type Range interface {
	IsActive(now time.Time) bool
	NextEdge(now time.Time) time.Time
}

Range represents a time range.

Jump to

Keyboard shortcuts

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