From cd3344edd1ef3ce0e7412909297d2c1146fd9c24 Mon Sep 17 00:00:00 2001 From: Seyed Hossein Hosseini Motlagh <56874737+hossein-225@users.noreply.github.com> Date: Mon, 27 May 2024 14:06:56 +0330 Subject: [PATCH] Adds the ToDuration function to the paypalExpirationTime type. This function allows easy conversion of the internal value to a time.Duration type, which is crucial when using paypalExpirationTime values with Redis expiration times. (#265) --- types.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types.go b/types.go index ee645b1..d695dd1 100644 --- a/types.go +++ b/types.go @@ -1649,3 +1649,9 @@ func (e *expirationTime) UnmarshalJSON(b []byte) error { *e = expirationTime(i) return nil } + +// Convert ExpirationTime to time.Duration +func (e *expirationTime) ToDuration() time.Duration { + seconds := int64(*e) + return time.Duration(seconds) * time.Second +} \ No newline at end of file