timestamp

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: Unlicense Imports: 6 Imported by: 0

Documentation

Overview

Package timestamp is a set of helpers for working with timestamps including encoding and conversion to various integer forms, from time.Time and varints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type T

type T struct{ V int64 }

T is a convenience type for UNIX 64 bit timestamps of 1 second precision.

func FromBytes

func FromBytes(b []byte) *T

FromBytes converts from a string of raw bytes.

func FromTime

func FromTime(t time.Time) *T

FromTime returns a T from a time.Time

func FromUnix

func FromUnix(t int64) *T

FromUnix converts from a standard int64 unix timestamp.

func FromVarint

func FromVarint(b []byte) (t *T, rem []byte, err error)

FromVarint decodes a varint and returns the remainder of the bytes and the encoded timestamp.T.

func New

func New(x ...int64) (t *T)

New creates a new timestamp.T, as zero or optionally from teh first variadic parameter as int64.

func Now

func Now() *T

Now returns the current UNIX timestamp of the current second.

func (*T) Bytes

func (t *T) Bytes() (b []byte)

Bytes returns a timestamp as an 8 byte thing.

func (*T) FromInt

func (t *T) FromInt(i int)

func (*T) I64

func (t *T) I64() int64

I64 returns the current UNIX timestamp of the current second as int64.

func (*T) Int

func (t *T) Int() int

Int returns the timestamp as an int.

func (*T) Marshal

func (t *T) Marshal(dst []byte) (b []byte)

Marshal a timestamp.T into bytes and append to a provided byte slice.

func (*T) MarshalJSON

func (t *T) MarshalJSON() ([]byte, error)

MarshalJSON marshals a timestamp.T using the json MarshalJSON interface.

func (*T) String

func (t *T) String() (s string)

String renders a timestamp.T as a string.

func (*T) Time

func (t *T) Time() time.Time

Time converts a timestamp.Time value into a canonical UNIX 64 bit 1 second precision timestamp.

func (*T) U64

func (t *T) U64() uint64

U64 returns the current UNIX timestamp of the current second as uint64.

func (*T) Unmarshal

func (t *T) Unmarshal(b []byte) (r []byte, err error)

Unmarshal a byte slice with an encoded timestamp.T value and append it to a provided byte slice.

Jump to

Keyboard shortcuts

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