1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-24 01:25:58 +01:00

Fix incorrect comment in rtptime.go.

Also use Duration.Abs.
This commit is contained in:
Juliusz Chroboczek 2023-12-09 17:44:02 +01:00
parent bee1c3d0c3
commit d2380f25b3
2 changed files with 2 additions and 6 deletions

View file

@ -10,10 +10,9 @@ import (
var epoch = time.Now()
// FromDuration converts a time.Duration into units of 1/hz.
// Negative values are clamped to zero.
func FromDuration(d time.Duration, hz uint32) int64 {
if d < 0 {
return -FromDuration(-d, hz)
return -FromDuration(d.Abs(), hz)
}
hi, lo := bits.Mul64(uint64(d), uint64(hz))
q, _ := bits.Div64(hi, lo, uint64(time.Second))

View file

@ -82,10 +82,7 @@ func TestNTP(t *testing.T) {
now2 := NTPToTime(ntp)
ntp2 := TimeToNTP(now2)
diff1 := now2.Sub(now)
if diff1 < 0 {
diff1 = -diff1
}
diff1 := now2.Sub(now).Abs()
if diff1 > time.Nanosecond {
t.Errorf("Expected %v, got %v (diff=%v)",
now, now2, diff1)