Documentation ¶
Index ¶
- func MaxTime(a time.Time, b time.Time) time.Time
- func MinTime(a time.Time, b time.Time) time.Time
- type BaseInterval
- type ClosedInterval
- func (t ClosedInterval) Combine(t2 ClosedInterval) ClosedInterval
- func (span ClosedInterval) Duration() time.Duration
- func (span ClosedInterval) Empty() bool
- func (t ClosedInterval) Expand(delta time.Duration) ClosedInterval
- func (interval ClosedInterval) ExpandToIncludeTime(t time.Time) ClosedInterval
- func (span ClosedInterval) Includes(query time.Time) bool
- func (t ClosedInterval) Intersect(t2 ClosedInterval) ClosedInterval
- func (t1 ClosedInterval) Overlaps(t2 ClosedInterval) bool
- type HalfOpenInterval
- func (t HalfOpenInterval) Combine(t2 HalfOpenInterval) HalfOpenInterval
- func (t1 HalfOpenInterval) Contains(t2 HalfOpenInterval) bool
- func (span HalfOpenInterval) Duration() time.Duration
- func (span HalfOpenInterval) Empty() bool
- func (t HalfOpenInterval) Expand(delta time.Duration) HalfOpenInterval
- func (span HalfOpenInterval) Includes(query time.Time) bool
- func (t HalfOpenInterval) Intersect(t2 HalfOpenInterval) HalfOpenInterval
- func (t1 HalfOpenInterval) Overlaps(t2 HalfOpenInterval) bool
- type TimeSpan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseInterval ¶
type ClosedInterval ¶
type ClosedInterval BaseInterval
A closed interval of time. Empty intervals are represented by having Start > End.
func NewClosedInterval ¶
func NewClosedInterval(start time.Time, end time.Time) ClosedInterval
func (ClosedInterval) Combine ¶
func (t ClosedInterval) Combine(t2 ClosedInterval) ClosedInterval
Return the smallest interval containing the start and end points of the two intervals, even if they are empty. That is, the maximum of end times and the minimum of start times.
func (ClosedInterval) Duration ¶
func (span ClosedInterval) Duration() time.Duration
func (ClosedInterval) Empty ¶
func (span ClosedInterval) Empty() bool
func (ClosedInterval) Expand ¶
func (t ClosedInterval) Expand(delta time.Duration) ClosedInterval
Extend an interval by "delta" in each direction (thus it gets 2*delta longer.) If it was empty, expand around the start point.
func (ClosedInterval) ExpandToIncludeTime ¶
func (interval ClosedInterval) ExpandToIncludeTime(t time.Time) ClosedInterval
Extend an interval to include the given time. If the interval is empty, then the result will be the singleton interval containing the given time.
func (ClosedInterval) Includes ¶
func (span ClosedInterval) Includes(query time.Time) bool
Determines whether the span includes the given query.
func (ClosedInterval) Intersect ¶
func (t ClosedInterval) Intersect(t2 ClosedInterval) ClosedInterval
Return the portion of this interval that lies entirely within another closed interval. Intersection with an open interval or half-open interval is not provided because the result might either be open or closed, and that's a pain to deal with (the point of splitting them out was to stop confusing the type of interval involved and be able to statically type-check it!)
func (ClosedInterval) Overlaps ¶
func (t1 ClosedInterval) Overlaps(t2 ClosedInterval) bool
Determine whether there is an overlap between two closed intervals
type HalfOpenInterval ¶
type HalfOpenInterval BaseInterval
An half-open interval [start,end) Empty intervals are represented by having Start >= End.
func NewHalfOpenInterval ¶
func NewHalfOpenInterval(start time.Time, end time.Time) HalfOpenInterval
func (HalfOpenInterval) Combine ¶
func (t HalfOpenInterval) Combine(t2 HalfOpenInterval) HalfOpenInterval
Return the smallest interval containing the start and end points of the two intervals, even if they are empty. That is, the maximum of end times and the minimum of start times,
The important use case for handling events is that the zero-length interval [a,a) can be combined with a non-empty interval [b,c) not including a to produce [a,c) or [b,a).
func (HalfOpenInterval) Contains ¶
func (t1 HalfOpenInterval) Contains(t2 HalfOpenInterval) bool
Returns true if t2 is entirely contained within t1 (i.e., a subset)
func (HalfOpenInterval) Duration ¶
func (span HalfOpenInterval) Duration() time.Duration
func (HalfOpenInterval) Empty ¶
func (span HalfOpenInterval) Empty() bool
func (HalfOpenInterval) Expand ¶
func (t HalfOpenInterval) Expand(delta time.Duration) HalfOpenInterval
Extend an interval by "delta" in each direction (thus it gets 2*delta longer.) If empty, return an interval of size 2 * delta around the start point.
func (HalfOpenInterval) Includes ¶
func (span HalfOpenInterval) Includes(query time.Time) bool
Determines whether the interval includes the given query.
func (HalfOpenInterval) Intersect ¶
func (t HalfOpenInterval) Intersect(t2 HalfOpenInterval) HalfOpenInterval
Return the intersection of two half-open intervals. (i.e., trim this interval to lie entirely within another.) May result in an interval with end <= start, which should be treated as empty.
func (HalfOpenInterval) Overlaps ¶
func (t1 HalfOpenInterval) Overlaps(t2 HalfOpenInterval) bool
type TimeSpan ¶
type TimeSpan = HalfOpenInterval