summaryrefslogtreecommitdiff
path: root/duration.go
diff options
context:
space:
mode:
Diffstat (limited to 'duration.go')
-rw-r--r--duration.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/duration.go b/duration.go
index 96722c9..ea25d47 100644
--- a/duration.go
+++ b/duration.go
@@ -4,6 +4,7 @@ import (
"errors"
"time"
+ "google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
)
@@ -31,6 +32,12 @@ func DurationCheck(maybeTime any) (time.Duration, error) {
case time.Time:
// If the type is time.Time, 'v' is now a time.Time variable.
d = time.Since(v)
+ case time.Duration:
+ // If the type is time.Time, 'v' is now a time.Time variable.
+ d = v
+ case *time.Duration:
+ // If the type is time.Time, 'v' is now a time.Time variable.
+ d = *v
case string:
// The type is string, so 'v' is a string variable.
// t, err = doTimeString(v)
@@ -44,7 +51,10 @@ func DurationCheck(maybeTime any) (time.Duration, error) {
} else {
err = errors.New("pb time invalid")
}
-
+ case *durationpb.Duration:
+ d = v.AsDuration()
+ case durationpb.Duration:
+ d = v.AsDuration()
case timestamppb.Timestamp:
// Handle the less common case of a value type instead of a pointer.
if v.IsValid() {