timestamp

package module
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 13 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 (
	ErrInvalidLength        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflow          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	// ErrEmptyTimestamp is returned if the timestamp was empty.
	ErrEmptyTimestamp = errors.New("timestamp is empty")
)
View Source
var File_github_com_aperturerobotics_timestamp_timestamp_proto protoreflect.FileDescriptor

Functions

func ToTime

func ToTime(t uint64) time.Time

ToTime generates a time object from a millisecond timestamp.

func ToUnixMs added in v0.7.0

func ToUnixMs(t time.Time) uint64

ToUnixMs converts a time to unix ms.

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"`
	// contains filtered or unexported fields
}

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) CloneMessageVT added in v0.7.0

func (m *Timestamp) CloneMessageVT() proto.Message

func (*Timestamp) CloneVT added in v0.7.0

func (m *Timestamp) CloneVT() *Timestamp

func (*Timestamp) Descriptor deprecated

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

Deprecated: Use Timestamp.ProtoReflect.Descriptor instead.

func (*Timestamp) EqualMessageVT added in v0.7.0

func (this *Timestamp) EqualMessageVT(thatMsg proto.Message) bool

func (*Timestamp) EqualVT added in v0.6.0

func (this *Timestamp) EqualVT(that *Timestamp) bool

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) Format added in v0.7.2

func (t *Timestamp) Format(formatStr string) string

Format formats using time.Format.

func (*Timestamp) GetEmpty added in v0.7.1

func (t *Timestamp) GetEmpty() bool

GetEmpty checks if the timestamp is empty.

func (*Timestamp) GetTimeUnixMs

func (x *Timestamp) GetTimeUnixMs() uint64

func (*Timestamp) MarshalJSON added in v0.7.0

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

MarshalJSON marshals to a JSON RFC3339 timestamp.

func (*Timestamp) MarshalToSizedBufferVT added in v0.5.1

func (m *Timestamp) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Timestamp) MarshalToVT added in v0.5.1

func (m *Timestamp) MarshalToVT(dAtA []byte) (int, error)

func (*Timestamp) MarshalVT added in v0.5.1

func (m *Timestamp) MarshalVT() (dAtA []byte, err error)

func (*Timestamp) ProtoMessage

func (*Timestamp) ProtoMessage()

func (*Timestamp) ProtoReflect added in v0.5.1

func (x *Timestamp) ProtoReflect() protoreflect.Message

func (*Timestamp) Reset

func (x *Timestamp) Reset()

func (*Timestamp) SizeVT added in v0.5.1

func (m *Timestamp) SizeVT() (n int)

func (*Timestamp) String

func (x *Timestamp) String() string

func (*Timestamp) ToRFC3339 added in v0.7.2

func (t *Timestamp) ToRFC3339() string

ToRFC3339 formats the timestamp as RFC3339

func (*Timestamp) ToTime

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

ToTime converts the Timestamp to a time.Time

func (*Timestamp) UnmarshalJSON added in v0.7.0

func (t *Timestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals json. Supports string (unix milliseconds large value or RFC3339 timestamp), number (unix milliseconds)

func (*Timestamp) UnmarshalVT added in v0.5.1

func (m *Timestamp) UnmarshalVT(dAtA []byte) error

func (*Timestamp) Validate

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

Validate checks the timestamp.

Jump to

Keyboard shortcuts

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