gRPC migration update
Change-Id: Icdd1a824948fa994cd36bd121c962f5ecf74e3cf
diff --git a/pkg/format/formatter_funcs.go b/pkg/format/formatter_funcs.go
index 6d10514..41be2f4 100644
--- a/pkg/format/formatter_funcs.go
+++ b/pkg/format/formatter_funcs.go
@@ -16,9 +16,9 @@
package format
import (
- "github.com/golang/protobuf/ptypes"
- timestamppb "github.com/golang/protobuf/ptypes/timestamp"
"time"
+
+ timestamppb "github.com/golang/protobuf/ptypes/timestamp"
)
// formats a Timestamp proto as a RFC3339 date string
@@ -26,11 +26,12 @@
if tsproto == nil {
return "", nil
}
- ts, err := ptypes.Timestamp(tsproto)
- if err != nil {
- return "", err
- }
- return ts.Truncate(time.Second).Format(time.RFC3339), nil
+ return tsproto.AsTime().Truncate(time.Second).Format(time.RFC3339), nil
+}
+
+// Computes the age of a timestamp and returns it in HMS format
+func formatGoSince(ts time.Time) (string, error) {
+ return time.Since(ts).Truncate(time.Second).String(), nil
}
// Computes the age of a timestamp and returns it in HMS format
@@ -38,9 +39,5 @@
if tsproto == nil {
return "", nil
}
- ts, err := ptypes.Timestamp(tsproto)
- if err != nil {
- return "", err
- }
- return time.Since(ts).Truncate(time.Second).String(), nil
+ return time.Since(tsproto.AsTime()).Truncate(time.Second).String(), nil
}