timestamppb

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2025 License: Apache-2.0 Imports: 13 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Timestamp

type Timestamp struct {
	// Represents seconds of UTC time since Unix epoch
	// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
	// 9999-12-31T23:59:59Z inclusive.
	Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
	// Non-negative fractions of a second at nanosecond resolution. Negative
	// second values with fractions must still have non-negative nanos values
	// that count forward in time. Must be from 0 to 999,999,999
	// inclusive.
	Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
}

Timestamp is a wrapped timestamppb.Timestamp with proper JSON and XML marshaling (as string date).

func New

func New(t time.Time) *Timestamp

New constructs a new Timestamp from the provided time.Time.

func Now added in v0.3.0

func Now() *Timestamp

Now constructs a new Timestamp from the current time.

func (*Timestamp) AppendFormat

func (ts *Timestamp) AppendFormat(b []byte, layout string) []byte

func (*Timestamp) AsTime

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

AsTime converts x to a time.Time.

func (*Timestamp) CheckValid added in v0.3.0

func (x *Timestamp) CheckValid() error

CheckValid returns an error if the timestamp is invalid. In particular, it checks whether the value represents a date that is in the range of 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive. An error is reported for a nil Timestamp.

func (*Timestamp) Format

func (ts *Timestamp) Format(layout string) string

func (*Timestamp) IsValid added in v0.3.0

func (x *Timestamp) IsValid() bool

IsValid reports whether the timestamp is valid. It is equivalent to CheckValid == nil.

func (*Timestamp) IsZero

func (ts *Timestamp) IsZero() (zero bool)

func (*Timestamp) MarshalJSON

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

func (*Timestamp) MarshalProtobuf added in v0.3.0

func (ts *Timestamp) MarshalProtobuf(dst []byte) []byte

MarshalProtobuf marshals ts into protobuf message, appends this message to dst and returns the result.

This function doesn't allocate memory on repeated calls.

func (*Timestamp) MarshalText

func (ts *Timestamp) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. The time is formatted in RFC 3339 format, with sub-second precision added if present.

func (*Timestamp) MarshalXML

func (ts *Timestamp) MarshalXML(enc *xml.Encoder, start xml.StartElement) error

func (*Timestamp) Proto

func (ts *Timestamp) Proto()

func (*Timestamp) ProtoMessage added in v0.3.0

func (*Timestamp) ProtoMessage()

func (*Timestamp) Reset

func (x *Timestamp) Reset()

func (*Timestamp) Scan

func (ts *Timestamp) Scan(src interface{}) error

func (*Timestamp) String

func (ts *Timestamp) String() string

func (*Timestamp) UnmarshalJSON

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

func (*Timestamp) UnmarshalProtobuf added in v0.3.0

func (ts *Timestamp) UnmarshalProtobuf(src []byte) (err error)

UnmarshalProtobuf unmarshals ts from protobuf message at src.

func (*Timestamp) UnmarshalText

func (ts *Timestamp) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The time is expected to be in RFC 3339 format.

func (*Timestamp) UnmarshalXML

func (ts *Timestamp) UnmarshalXML(dec *xml.Decoder, st xml.StartElement) error

func (*Timestamp) Value

func (ts *Timestamp) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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