interval

package
v0.0.0-...-1dc6284 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package interval provides a struct representing a time interval.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interval

type Interval struct {
	Start, End time.Time
}

Interval represents the interval [Start, End).

func (*Interval) RandomSecond

func (i *Interval) RandomSecond() time.Time

RandomSecond returns a random second-precision time that falls within the Interval.

If there is no second-precision time that falls in the Interval, the zero value time.Time will be returned. For example:

Start = 2019-03-25 00:00:00.1 +0000 UTC
End = 2019-03-25 00:00:00.9 +0000 UTC

If Interval.End == Interval.Start, the zero value time.Time will be returned. This is because an Interval represents the interval [Interval.Start, Interval.End), so if Interval.Start and Interval.End are equal, the interval is invalid.

If Interval.End < Interval.Start, the zero value time.Time will be returned.

If the Interval is nil, the zero value time.Time will be returned.

Jump to

Keyboard shortcuts

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