util

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// a short time format; like time.Kitchen but with 24-hour notation.
	Kitchen24 = "15:04"
	// a time format that just cares about the day and month.
	YearDay = "Jan_2"
)

Variables

This section is empty.

Functions

func NewPod added in v0.7.0

func NewPod(namespace, name string) v1.Pod

NewPod returns a new pod instance for testing purposes.

func ParseDays added in v0.8.0

func ParseDays(days string) ([]time.Time, error)

func ParseWeekdays added in v0.7.0

func ParseWeekdays(weekdays string) []time.Weekday

ParseWeekdays takes a comma-separated list of abbreviated weekdays (e.g. sat,sun) and turns them into a slice of time.Weekday. It ignores any whitespace and any invalid weekdays.

func TimeOfDay added in v0.8.0

func TimeOfDay(pointInTime time.Time) time.Time

TimeOfDay normalizes the given point in time by returning a time object that represents the same time of day of the given time but on the very first day (day 0).

Types

type TimePeriod added in v0.8.0

type TimePeriod struct {
	From time.Time
	To   time.Time
}

TimePeriod represents a time period with a single beginning and end.

func NewTimePeriod added in v0.8.0

func NewTimePeriod(from, to time.Time) TimePeriod

NewTimePeriod returns a normalized TimePeriod given a start and end time.

func ParseTimePeriods added in v0.8.0

func ParseTimePeriods(timePeriods string) ([]TimePeriod, error)

ParseTimePeriods takes a comma-separated list of time periods in Kitchen24 format and turns them into a slice of TimePeriods. It ignores any whitespace.

func (TimePeriod) Includes added in v0.8.0

func (tp TimePeriod) Includes(pointInTime time.Time) bool

Includes returns true iff the given pointInTime's time of day is included in time period tp.

func (TimePeriod) String added in v0.8.0

func (tp TimePeriod) String() string

String returns tp as a pretty string.

Jump to

Keyboard shortcuts

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