mirror of
https://github.com/jech/galene.git
synced 2024-11-08 17:55:59 +01:00
Fix incorrect comment in rtptime.go.
Also use Duration.Abs.
This commit is contained in:
parent
bee1c3d0c3
commit
d2380f25b3
2 changed files with 2 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue