Documentation ¶
Index ¶
- Variables
- type Ordering
- type Timeframe
- func (t Timeframe) Compare(x time.Time) Ordering
- func (t Timeframe) CompareDuration(d time.Duration) int
- func (t Timeframe) Contains(a time.Time) bool
- func (t Timeframe) Duration() time.Duration
- func (t Timeframe) Format(layout string) string
- func (t Timeframe) IsFinite() bool
- func (t Timeframe) MarshalColumn() ([]byte, error)
- func (t Timeframe) String() string
- func (t *Timeframe) UnmarshalColumn(text []byte) error
Constants ¶
This section is empty.
Variables ¶
var Forever = Timeframe{}
A timeframe with no bounds, representing all of time
Functions ¶
This section is empty.
Types ¶
type Timeframe ¶
type Timeframe struct { Since *time.Time `json:"since" db:"since"` Until *time.Time `json:"until" db:"until"` }
A timeframe
func (Timeframe) Compare ¶ added in v1.37.0
Compare determines how the provided time orders relative to this timeframe; either: within it, before it begins, or after it ends. If the timeframe is not finite, any parameter time is within it.
As usual, the lower bound is inclusive and the upper bound is exclusive.
func (Timeframe) CompareDuration ¶
CompareDuration compares the duration between t.Since and t.Until with the given duration
func (Timeframe) Contains ¶
Determine if the timeframe contains the specified time. Timeframes are inclusive on the lower bound and exclusive on the upper bound.
func (Timeframe) Duration ¶
What is the duration of the timeframe. If a timeframe is not bounded on both ends, the duration is infinite, which is expressed as a negative value. If Until is before Since, the value will also be negative, this is a logically invalid state that is interpreted as the timeframe being unbounded.