time

package
v0.203.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 3 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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