Skip to content

Commit

Permalink
feat: add timestamp ToTimestamp alias
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <christian@aperture.us>
  • Loading branch information
paralin committed Apr 22, 2024
1 parent 2771ae1 commit 45f5a68
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions types/known/timestamppb/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ import (
"errors"
"strconv"
"strings"
time "time"

"github.com/aperturerobotics/protobuf-go-lite/json"
)

// 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
Expand Down

0 comments on commit 45f5a68

Please sign in to comment.