time

package
v0.95.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Time

type Time struct {
	// contains filtered or unexported fields
}

Time is a wrapper for timestamppb.Timestamp to provide custom marshaling for JSON and URL query strings.

It embeds timestamppb.Timestamp and exposes the .AsTime() method to easily convert to time.Time.

Example:

customTime := time.New(stdtime.Now())
goTime := customTime.AsTime()

func New

func New(t time.Time) *Time

New creates a custom Time from a standard time.Time.

func (*Time) AsTime

func (x *Time) AsTime() time.Time

AsTime returns the underlying time.Time value.

func (Time) EncodeValues

func (t Time) EncodeValues(key string, v *url.Values) error

EncodeValues implements the [query.Encoder] interface by encoding the time as a protobuf Timestamp.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements the [json.Marshaler] interface by marshalling the time as a protobuf Timestamp.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the [json.Unmarshaler] interface by unmarshalling the time from a protobuf Timestamp.

Jump to

Keyboard shortcuts

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