Commit d2380f25 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Fix incorrect comment in rtptime.go.

Also use Duration.Abs.
parent bee1c3d0
......@@ -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))
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment