Skip to content

Commit

Permalink
Adds the ToDuration function to the paypalExpirationTime type. This f…
Browse files Browse the repository at this point in the history
…unction allows easy conversion of the internal value to a time.Duration type, which is crucial when using paypalExpirationTime values with Redis expiration times. (#265)
  • Loading branch information
hossein-225 authored May 27, 2024
1 parent b8f2c8c commit cd3344e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit cd3344e

Please sign in to comment.