timestamp

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 5 Imported by: 2

README

Timestamp

Standard cross-language timestamp object.

Introduction

This is a simple protobuf encoding for timestamps.

Note: in most cases you will want to use the built-in Protobuf timestamp. This is just a helpful implementation for those cases where a simpler uint64 millisecond representation makes more sense.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyTimestamp is returned if the timestamp was empty.
	ErrEmptyTimestamp = errors.New("timestamp is empty")
)

Functions

func ToTime

func ToTime(t uint64) time.Time

ToTime generates a time object from a millisecond timestamp.

Types

type Timestamp

type Timestamp struct {
	// TimeUnixMs timestamp in unix milliseconds.
	TimeUnixMs           uint64   `protobuf:"varint,1,opt,name=time_unix_ms,json=timeUnixMs,proto3" json:"time_unix_ms,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Timestamp contains a cross-platform timestamp.

func Now

func Now() Timestamp

Now returns a timestamp for now.

func ToTimestamp

func ToTimestamp(t time.Time) Timestamp

ToTimestamp generates a millisecond timestamp from the time object.

func (*Timestamp) Clone added in v0.4.0

func (t *Timestamp) Clone() *Timestamp

Clone copies the timestamp.

func (*Timestamp) Descriptor

func (*Timestamp) Descriptor() ([]byte, []int)

func (*Timestamp) Equals added in v0.4.0

func (t *Timestamp) Equals(ot *Timestamp) bool

Equals checks if the timestamp equals another timestamp.

func (*Timestamp) GetTimeUnixMs

func (m *Timestamp) GetTimeUnixMs() uint64

func (*Timestamp) ProtoMessage

func (*Timestamp) ProtoMessage()

func (*Timestamp) Reset

func (m *Timestamp) Reset()

func (*Timestamp) String

func (m *Timestamp) String() string

func (*Timestamp) ToTime

func (t *Timestamp) ToTime() time.Time

ToTime converts the Timestamp to a time.Time

func (*Timestamp) Validate

func (t *Timestamp) Validate(allowEmpty bool) error

Validate checks the timestamp.

func (*Timestamp) XXX_DiscardUnknown added in v0.4.0

func (m *Timestamp) XXX_DiscardUnknown()

func (*Timestamp) XXX_Marshal added in v0.4.0

func (m *Timestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Timestamp) XXX_Merge added in v0.4.0

func (m *Timestamp) XXX_Merge(src proto.Message)

func (*Timestamp) XXX_Size added in v0.4.0

func (m *Timestamp) XXX_Size() int

func (*Timestamp) XXX_Unmarshal added in v0.4.0

func (m *Timestamp) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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