aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/golang/protobuf/ptypes/timestamp.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/golang/protobuf/ptypes/timestamp.go')
-rw-r--r--vendor/github.com/golang/protobuf/ptypes/timestamp.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp.go b/vendor/github.com/golang/protobuf/ptypes/timestamp.go
index 1b36576..47f10db 100644
--- a/vendor/github.com/golang/protobuf/ptypes/timestamp.go
+++ b/vendor/github.com/golang/protobuf/ptypes/timestamp.go
@@ -99,6 +99,15 @@ func Timestamp(ts *tspb.Timestamp) (time.Time, error) {
return t, validateTimestamp(ts)
}
+// TimestampNow returns a google.protobuf.Timestamp for the current time.
+func TimestampNow() *tspb.Timestamp {
+ ts, err := TimestampProto(time.Now())
+ if err != nil {
+ panic("ptypes: time.Now() out of Timestamp range")
+ }
+ return ts
+}
+
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
// It returns an error if the resulting Timestamp is invalid.
func TimestampProto(t time.Time) (*tspb.Timestamp, error) {