Documentation ¶
Index ¶
- Constants
- Variables
- type Duration
- type Span
- func (s Span) Contains(ts Ts) bool
- func (s Span) ContainsClosed(ts Ts) bool
- func (s Span) Covers(covered Span) bool
- func (s Span) End() Ts
- func (s Span) Intersect(b Span) Span
- func (s Span) MinDur(minDur Duration, fanout int) Duration
- func (s Span) Overlaps(comp Span) bool
- func (s Span) OverlapsOrAdjacent(comp Span) bool
- func (s Span) Partition(ts Ts, n int) int
- func (s Span) Pretty() string
- func (s Span) String() string
- func (s Span) SubSpan(i, n int) Span
- func (s Span) Subtract(b Span) []Span
- func (s Span) Union(b Span) Span
- type Ts
- func (t Ts) Add(d Duration) Ts
- func (t Ts) DayOf() Span
- func (t Ts) MarshalJSON() ([]byte, error)
- func (t Ts) Midnight() Ts
- func (t Ts) Pretty() string
- func (t Ts) Split() (int64, int64)
- func (t Ts) String() string
- func (t Ts) Sub(d Duration) Ts
- func (t Ts) SubTs(u Ts) Duration
- func (t Ts) Time() time.Time
- func (t Ts) Trunc(bin Duration) Ts
- func (t *Ts) UnmarshalJSON(in []byte) error
Constants ¶
const ( Nanosecond Duration = 1 Microsecond = 1000 * Nanosecond Millisecond = 1000 * Microsecond Second = 1000 * Millisecond Minute = 60 * Second Hour = 60 * Minute Day = 24 * Hour Week = 7 * Day Year = 365 * Day )
Variables ¶
var MaxSpan = Span{Ts: 0, Dur: math.MaxInt64}
MaxSpan is a range from the minimum possible time to the max possible time.
Functions ¶
This section is empty.
Types ¶
type Duration ¶
type Duration int64
func DurationFromParts ¶
func MinDurForDay ¶
func ParseDuration ¶
func (Duration) MarshalJSON ¶
func (*Duration) UnmarshalJSON ¶
type Span ¶
Span represents a time span. Spans are half-open: [Ts, Ts + Dur).
func (Span) ContainsClosed ¶
ContainsClose returns true if the timestamp is in the time interval including the end of interval.
func (Span) End ¶
End returns the first Ts after the Span (in other words, the smallest Ts greater than every Ts in the Span).
func (Span) Intersect ¶
Intersect merges two spans returning a new span representing the intesection of the two spans. If the spans do not overlap, a zero valued span is returned.
func (Span) MinDur ¶
MinDur returns the smallest duration >= minDur among spans that would be partioned in a span tree of degree fanout.
func (Span) OverlapsOrAdjacent ¶
OverlapsOrAdjacent returns true if the two spans overlaps each or are adjacent.
func (Span) Partition ¶
Partition divides the span into n subspans of approximately equal length and returns the index of the subspan containing ts.
func (Span) SubSpan ¶
SubSpan divides the span into n subspans of approximately equal length and returns the i-th.
type Ts ¶
type Ts int64
func ParseMillis ¶
ParseMillis parses an unsigned integer representing milliseconds since the Unix epoch.
func ParseRFC3339Nano ¶
ParseRFC3339Nano parses a byte according to the time.RFC3339Nano format into a Ts, returning an error if parsing failed.
func Unix ¶
Unix returns a Ts corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970 UTC.