utils: use time.Duration.Abs (#4217)

This function was added in Go 1.19, and covers some corner cases that
our custom implementation didn't.
This commit is contained in:
Marten Seemann
2023-12-28 11:49:47 +07:00
committed by GitHub
parent d795250479
commit 18c591c75a
3 changed files with 2 additions and 15 deletions

View File

@@ -35,14 +35,6 @@ func MinNonZeroDuration(a, b time.Duration) time.Duration {
return Min(a, b)
}
// AbsDuration returns the absolute value of a time duration
func AbsDuration(d time.Duration) time.Duration {
if d >= 0 {
return d
}
return -d
}
// MinTime returns the earlier time
func MinTime(a, b time.Time) time.Time {
if a.After(b) {