util

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 7 Imported by: 13

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 FormatDays added in v0.15.0

func FormatDays(days []time.Time) []string

FormatDays takes a slice of times and returns a slice of strings in YearDate format (e.g. [Apr 1, Sep 24])

func NewNamespace added in v0.15.1

func NewNamespace(name string) v1.Namespace

NewNamespace returns a new namespace instance for testing purposes.

func NewPod added in v0.7.0

func NewPod(namespace, name string, phase v1.PodPhase) v1.Pod

NewPod returns a new pod instance for testing purposes.

func NewPodWithOwner added in v0.16.0

func NewPodWithOwner(namespace, name string, phase v1.PodPhase, owner types.UID) v1.Pod

NewPodWithOwner returns a new pod instance for testing purposes with a given owner UID

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 RandomPodSubSlice added in v0.16.0

func RandomPodSubSlice(pods []v1.Pod, count int) []v1.Pod

RandomPodSubSlice creates a shuffled subslice of the give pods slice

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