`import "github.com/abhinavdahiya/cockroach/util/duration"`

- Variables
- func Add(t time.Time, d Duration) time.Time
- type Duration
- func Decode(sortNanos int64, months int64, days int64) (Duration, error)
- func (d Duration) Add(x Duration) Duration
- func (d Duration) Compare(x Duration) int
- func (d Duration) Div(x int64) Duration
- func (d Duration) Encode() (sortNanos int64, months int64, days int64, err error)
- func (d Duration) EncodeBigInt() (sortNanos *big.Int, months int64, days int64)
- func (d Duration) Mul(x int64) Duration
- func (d Duration) String() string
- func (d Duration) Sub(x Duration) Duration

ErrEncodeOverflow is returned by Encode when the sortNanos returned would have overflowed or underflowed.

Add returns the time t+d.

A Duration represents a length of time.

A duration of "1 month" cannot be represented as a fixed number of nanoseconds because the length of months vary. The same is true for days because of leap seconds. Given a begin or end time to anchor a duration, the nanosecond count can be calculated, but it's useful to represent durations such as "1 year 3 months" without an anchor. Duration allows this.

For the purposes of Compare and Encode, 1 month is considered equivalent to 30 days and 1 day is equivalent to 24 * 60 * 60 * 1E9 nanoseconds.

TODO(dan): Until the overflow and underflow handling is fixed, this is only useful for durations of < 292 years.

Decode reverses the three integers returned from Encode and produces an equal Duration to the original.

Add returns a Duration representing a time length of d+x.

Compare returns an integer representing the relative length of two Durations. The result will be 0 if d==x, -1 if d < x, and +1 if d > x.

Div returns a Duration representing a time length of d/x.

Encode returns three integers such that the original Duration is recoverable (using Decode) and the first int will approximately sort a collection of encoded Durations.

EncodeBigInt is the same as Encode, except that it always returns successfully and is slower.

Mul returns a Duration representing a time length of d*x.

String returns a string representation of a Duration.

Sub returns a Duration representing a time length of d-x.

Package duration imports 5 packages (graph). Updated 2017-03-13. Refresh now. Tools for package owners. This is a dead-end fork (no commits since the fork).