Documentation ¶
Index ¶
- Constants
- type Interval
- func (i Interval) Contains(t time.Time) bool
- func (i Interval) Days() float64
- func (i Interval) Duration() time.Duration
- func (i Interval) End() time.Time
- func (i *Interval) ExtendEnd(d time.Duration)
- func (i *Interval) ExtendStart(d time.Duration)
- func (i Interval) HalfOpenEnd() Interval
- func (i Interval) Hours() float64
- func (i Interval) IsValid() bool
- func (i Interval) IsZero() bool
- func (i Interval) Microseconds() float64
- func (i Interval) Milliseconds() float64
- func (i Interval) Minutes() float64
- func (i Interval) Nanoseconds() int64
- func (i Interval) Seconds() float64
- func (i Interval) Start() time.Time
- func (i Interval) String() string
- func (i Interval) StringDates() string
Constants ¶
const ( Nanosecond = units(time.Nanosecond) Microsecond = 1000 * Nanosecond Millisecond = 1000 * Microsecond Second = 1000 * Millisecond Minute = 60 * Second Hour = 60 * Minute Day = 24 * Hour Week = 7 * Day )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interval ¶
type Interval struct {
// contains filtered or unexported fields
}
Interval describes a time interval between start and end time values
func NewInterval ¶
NewInterval returns a new instance of Interval between start and end Input is order-independent, the smaller value will be used as the start when bigger as the end
func (Interval) Contains ¶
Contains reports whether t is within of i (closed interval strategy, start <= t <= end)
func (*Interval) ExtendEnd ¶ added in v1.2.0
ExtendEnd extends i to the end adding d for i.End() Example:
fmt.Println(i.End()) // 2021-07-03T10:30:00Z i.ExtendEnd(time.Day * 2) fmt.Println(i.End()) // 2021-07-05T10:30:00Z
func (*Interval) ExtendStart ¶ added in v1.2.0
ExtendStart extends i from the start back in time adding d in the form of i.Start.Add(-d) Example:
fmt.Println(i.Start()) // 2021-07-03T10:30:00Z i.ExtendStart(time.Day * 2) fmt.Println(i.Start()) // 2021-07-01T10:30:00Z
func (Interval) HalfOpenEnd ¶
HalfOpenEnd returns i as a half-open interval where the open side is on the end [start, end) Actually, it returns copy of i where end = end - 1 nanosecond
func (Interval) Microseconds ¶
Microseconds returns a duration of interval in microseconds
func (Interval) Milliseconds ¶
Milliseconds returns a duration of interval in milliseconds
func (Interval) Nanoseconds ¶
Nanoseconds returns a duration of interval in hours
func (Interval) StringDates ¶
StringDates returns string representation of i as date part only