Documentation ¶
Index ¶
- func AtomicStore(ts *TS, v TS)
- func OutOfRange(t time.Time) bool
- type TS
- func (ts TS) Add(d time.Duration) TS
- func (ts TS) AddDate(years, months, days int) TS
- func (ts TS) AddTS(ts2 TS) TS
- func (ts TS) After(ts2 TS) bool
- func (ts TS) AfterTime(t time.Time) bool
- func (ts TS) Before(ts2 TS) bool
- func (ts TS) BeforeTime(t time.Time) bool
- func (ts TS) Duration() time.Duration
- func (ts TS) Equal(ts2 TS) bool
- func (ts TS) EqualTS(ts2 TS) bool
- func (ts TS) EqualTime(t time.Time) bool
- func (ts TS) Format(layout string) string
- func (ts TS) In(loc *time.Location) time.Time
- func (ts TS) IsZero() bool
- func (ts TS) Location() *time.Location
- func (ts TS) MarshalBinary() ([]byte, error)
- func (ts TS) MarshalJSON() ([]byte, error)
- func (ts TS) MarshalText() ([]byte, error)
- func (ts TS) String() string
- func (ts TS) Sub(ts2 TS) time.Duration
- func (ts TS) SubTime(t time.Time) time.Duration
- func (ts TS) Time() time.Time
- func (ts TS) Truncate(d time.Duration) TS
- func (ts TS) TruncateTime(d time.Duration) time.Time
- func (ts TS) Unix() int64
- func (ts TS) UnixNano() int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtomicStore ¶ added in v0.0.3
AtomicStore changes atomically ts value.
func OutOfRange ¶
OutOfRange returns true if t is out of the timestamp representation range ( ~ 1970 +/- 292 years).
Types ¶
type TS ¶
A TS represents a time stamp with nanosecond precision. The zero value (Zero() method) correspond to the 0 unix time: 01.01.1970 00:00:00 UTC.
The timestamp range is approx. the zero unix time (1970) +/- 292 years.
All conversion to time.Time use UTC.
func AtomicLoad ¶ added in v0.0.3
AtomicLoad reads atomically the ts value.
func DurationToTS ¶
DurationToTS returns the time stamp corresponding to a given time.Duration.
func Timestamp ¶
Timestamp returns the time stamp corresponding to the given time (time.Time).// If it exceeds the maximum TS range it will return MaxTS or MinTS. The zero time.Time is specially handled and converted to a 0 timestamp (otherwise would be an out-of-range value).
func Unix ¶
Unix returns the local time stamp corresponding to the given unix time. See time.Unix for more details.
func (TS) AfterTime ¶
After returns true if ts > t, where t is a time.Time. Note that the result is undefined if t is outside the timestamp representation range.
func (TS) BeforeTime ¶
Before returns if ts < t, where t is a time.Time Note that the result is undefined if t is outside the timestamp representation range.
func (TS) EqualTime ¶
EqualTime returns if ts == t, where t is a time.Time. Note that the result is undefined if t is outside the timestamp representation range.
func (TS) In ¶
In returns the time stamp converted to time in the specified location. See also Time() and time.In(loc).
func (TS) Location ¶
Location returns the time zone information associated to the timestamp. It will always return UTC, since timestamps use only UTC.
func (TS) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (TS) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (TS) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (TS) String ¶
Sting returns the default string representation for the timestamp. (see time.String for more details) Since timestamps do not store a timezone, the string representation will always use UTC.
func (TS) SubTime ¶
Sub returns the difference ts - t., where t is a time.Time. Note that the result is undefined if t is outside the timestamp representation range.
func (TS) Time ¶
Time returns the time stamp converted to time. The 0 timestamp value is specially handled and converted to the zero time.Time (since otherwise the 0 timestamp would correpond to time.Unix(0,0).UTC()).
func (TS) Truncate ¶
Truncate returns the result of rounding ts down to d (see time.Truncate() for more details).
func (TS) TruncateTime ¶
Truncate returns the result of rounding ts down to d (see time.Truncate() for more details).