Aaahh, that makes total sense, thank you so much!
On Fri, Nov 11, 2016, 11:59 PM Jakob Borg wrote:
> You are dividing the number of nanoseconds since the Unix epoch by some
> random number of nanoseconds and chopping off the remainder. But a
> time.Time internally is an interval since another, m
You are dividing the number of nanoseconds since the Unix epoch by some random
number of nanoseconds and chopping off the remainder. But a time.Time
internally is an interval since another, much earlier, reference time. The
remainder in that division will be different.
//jb
> On 11 Nov 2016,
Here's a test case to show what I mean:
func TestWat(t *T) {
now := time.Now()
trunc := rand.Int63n(int64(time.Second))
t.Logf("trunc: %v", trunc)
t1 := now.Truncate(time.Duration(trunc))
t2 := time.Unix(0, trunc*(now.UnixNano()/trunc))
// this fails for some reason
assert.Equal(t, t1, t2)
}
Fo