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)

This commit is contained in:
Seyed Hossein Hosseini Motlagh 2024-05-27 14:06:56 +03:30 committed by GitHub
parent b8f2c8c573
commit cd3344edd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}