dnscrypt-proxy/vendor/github.com/quic-go/quic-go/internal/utils/minmax.go

37 lines
582 B
Go
Raw Normal View History

2022-07-21 18:50:10 +02:00
package utils
import (
"math"
"time"
)
// InfDuration is a duration of infinite length
const InfDuration = time.Duration(math.MaxInt64)
// MinNonZeroDuration return the minimum duration that's not zero.
func MinNonZeroDuration(a, b time.Duration) time.Duration {
if a == 0 {
return b
}
if b == 0 {
return a
}
2024-01-18 23:47:00 +01:00
return min(a, b)
2022-07-21 18:50:10 +02:00
}
// MinTime returns the earlier time
func MinTime(a, b time.Time) time.Time {
if a.After(b) {
return b
}
return a
}
// MaxTime returns the later time
func MaxTime(a, b time.Time) time.Time {
if a.After(b) {
return a
}
return b
}