Skip to content

Commit

Permalink
feat(timestamp): add FromUnixMilli
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed Jul 1, 2024
1 parent ddbc7f7 commit 723dfbe
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions types/known/timestamppb/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ func ToTimestamp(t time.Time) *Timestamp {
return New(t)
}

// FromUnixMilli constructs a new Timestamp from the provided unix milliseconds value.
//
// Example: time.Now().UnixMilli()
func FromUnixMilli(timestampUnixMilli int64) *Timestamp {
return New(time.UnixMilli(timestampUnixMilli))
}

// GetEmpty checks if the timestamp is empty.
func (x *Timestamp) GetEmpty() bool {
return x.SizeVT() == 0
Expand Down

0 comments on commit 723dfbe

Please sign in to comment.