diff --git a/types/known/timestamppb/timestamp.go b/types/known/timestamppb/timestamp.go index 0e8611b7..fb72081a 100644 --- a/types/known/timestamppb/timestamp.go +++ b/types/known/timestamppb/timestamp.go @@ -4,6 +4,7 @@ import ( "errors" "strconv" "strings" + time "time" "github.com/aperturerobotics/protobuf-go-lite/json" ) @@ -11,6 +12,11 @@ import ( // ErrEmptyTimestamp is returned from Validate if the timestamp was empty. var ErrEmptyTimestamp = errors.New("empty timestamp") +// ToTimestamp constructs a new Timestamp from the provided time.Time. +func ToTimestamp(t time.Time) *Timestamp { + return New(t) +} + // Validate is an alias to CheckValid. func (x *Timestamp) Validate(allowEmpty bool) error { isEmpty := x.SizeVT() == 0