timestamp

package module
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2022 License: MIT Imports: 1 Imported by: 3

README

timestamp

The timestamp package implements an alternative UTC type that encodes efficiently and safely on the client-side. Values use microsecond precision, the zero point is 1-1-1900 0:00 UTC. The encoding uses only 52 bits to fit safely in a IEEE double floating point value. This ensures compatibility with the Javascript number type.

There are a number of advantages timestamp has over using the official Time data type:

  • straightforward, compact encoding as a single int64 or double in memory and storage
  • due to always being UTC, no problems with timezones
  • direct compatiblity with Javascript or any other programming language that can handle 64bit integers
  • vendor-agnostic storage in databases as simple 64bit integer

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(ts1, ts2 TS) int64

Diff returns the differens (ts2-ts1) in millisecs

Types

type TS added in v1.1.0

type TS int64

TS encodes UTC time with microsecond resolution with a starting point of 1-1-1900 00:00 UTC

func Duration

func Duration(d time.Duration) TS

Duration converts a Duration value into a (relative) TS

func DurationMS

func DurationMS(millisecs int) TS

DurationMS creates a duration (offset) TS value from milliseconds

func Make

func Make(t time.Time) TS

Make converts a Time value into a TS

func Now

func Now() TS

Now returns the current time as a TS

func Unix added in v1.2.0

func Unix(ut int64) TS

Unix converts a Unix Epoch Time value into a TS timestamp

func (TS) Duration added in v1.1.0

func (ts TS) Duration() time.Duration

Duration converts a TS value into a golang time.Duration value

func (TS) Int64 added in v1.1.0

func (ts TS) Int64() int64

Int64 type-casts back to int64

func (TS) Milliseconds added in v1.3.0

func (ts TS) Milliseconds() float64

Milliseconds returns the absolute number of seconds since the base date (1/1/1900)

func (TS) Seconds added in v1.1.0

func (ts TS) Seconds() float64

Seconds returns the absolute number of seconds since the base date (1/1/1900)

func (TS) String added in v1.1.0

func (ts TS) String() string

String implements fmt.Stringer

func (TS) Time added in v1.1.0

func (ts TS) Time() time.Time

Time converts a TS value into a golang time.Time value

func (TS) Unix added in v1.2.0

func (ts TS) Unix() int64

Unix converts into Unix Epoch Time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL