We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3337d28 commit c823c79Copy full SHA for c823c79
ptypes/timestamp.go
@@ -111,11 +111,9 @@ func TimestampNow() *tspb.Timestamp {
111
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
112
// It returns an error if the resulting Timestamp is invalid.
113
func TimestampProto(t time.Time) (*tspb.Timestamp, error) {
114
- seconds := t.Unix()
115
- nanos := int32(t.Sub(time.Unix(seconds, 0)))
116
ts := &tspb.Timestamp{
117
- Seconds: seconds,
118
- Nanos: nanos,
+ Seconds: t.Unix(),
+ Nanos: int32(t.Nanosecond()),
119
}
120
if err := validateTimestamp(ts); err != nil {
121
return nil, err
0 commit comments