Categorygithub.com/intuitivelabs/timestamp
modulepackage
0.0.3
Repository: https://github.com/intuitivelabs/timestamp.git
Documentation: pkg.go.dev

# README

timestamp

Go Reference

The timestamp package provides a time.Time "compatible" way of keeping time stamps, using less space (single int64) and no pointers.

It implements most of time.Time functions, so switching to it should require only minimal work (most of the time the only thing required is replacing time.Time with timestamp.TS and time.Now() with timestamp.Now()).

Functions are provided for converting between time.Time and timestamp.TS (timestamp.Timestamp(t)) and vice-versa (timestamp.Time()).

The time stamp is kept in nanoseconds.

Limitations

  • timestamps are limited to ~ 1970 +/- 292 years

  • to check for out-of-range when converting from a time.Time value, one has to compare both with timestamp.MinTS and timestamp.MaxTS

  • string representation uses always UTC (since timezones are not supported). To use a different representation one has to go through time.Time, for example via timestamp.In:

     ts := timestamp.Now()
     fmt.Printf("ts UTC: %s , local: %s\n", ts, ts.In(time.Local))
    

# Functions

AtomicLoad reads atomically the ts value.
AtomicStore changes atomically ts value.
DurationToTS returns the time stamp corresponding to a given time.Duration.
Now returns the current time as a time stamp.
OutOfRange returns true if t is out of the timestamp representation range ( ~ 1970 +/- 292 years).
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.
Unix returns the local time stamp corresponding to the given unix time.
Zero returns the time stamp corresponding to the zero value.

# Constants

No description provided by the author
No description provided by the author

# Type aliases

A TS represents a time stamp with nanosecond precision.