Documentation ¶
Overview ¶
Package timespan provides functionality for handling intervals of time.
Index ¶
- type Span
- func (s Span) After(t time.Time) bool
- func (s Span) Before(t time.Time) bool
- func (s Span) Borders(r Span) bool
- func (s Span) Contains(r Span) bool
- func (s Span) ContainsTime(t time.Time) bool
- func (s Span) Duration() time.Duration
- func (s Span) Encompass(r Span) Span
- func (s Span) End() time.Time
- func (s Span) Equal(r Span) bool
- func (s Span) Follows(r Span) bool
- func (s Span) Gap(r Span) Span
- func (s Span) Intersection(r Span) (Span, bool)
- func (s Span) IsZero() bool
- func (s Span) Offset(d time.Duration) Span
- func (s Span) OffsetDate(years, months, days int) Span
- func (s Span) Overlaps(r Span) bool
- func (s Span) Precedes(r Span) bool
- func (s Span) Start() time.Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span represents an inclusive range between two time instants.
The zero value of type span has both start and end times set to the zero value of type Time. The zero value is returned by the Intersection and Gap methods when there is no span fitting their purposes.
func (Span) ContainsTime ¶
ContainsTime reports whether t is within s.
func (Span) Equal ¶
Equal reports whether s and r represent the same time intervals, ignoring the locations of the times.
func (Span) Gap ¶
Gap returns a span corresponding to the period between s and r. If s and r have a non-zero overlap, a zero span is returned.
func (Span) Intersection ¶
Intersection returns both a span corresponding to the non-zero overlap of s and r and a bool indicating whether such an overlap existed. If s and r do not overlap, a zero span is returned with false.
func (Span) IsZero ¶
IsZero reports whether s represents the zero-length span starting and ending on January 1, year 1, 00:00:00 UTC.
func (Span) Offset ¶
Offset returns s with its start time offset by d. It is equivalent to Newspan(s.Start().Add(d), s.Duration()).
func (Span) OffsetDate ¶
OffsetDate returns s with its start time offset by the given years, months, and days. It is equivalent to Newspan(s.Start().AddDate(years, months, days), s.Duration()).