aboutsummaryrefslogtreecommitdiffstats
path: root/tai64n/tai64n.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tai64n/tai64n.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/tai64n/tai64n.go b/tai64n/tai64n.go
index f402f05..565aaa4 100644
--- a/tai64n/tai64n.go
+++ b/tai64n/tai64n.go
@@ -12,7 +12,8 @@ import (
)
const TimestampSize = 12
-const base = uint64(4611686018427387914)
+const base = uint64(0x400000000000000a)
+const whitenerMask = uint32(0x1000000 - 1)
type Timestamp [TimestampSize]byte
@@ -20,7 +21,7 @@ func Now() Timestamp {
var tai64n Timestamp
now := time.Now()
secs := base + uint64(now.Unix())
- nano := uint32(now.Nanosecond())
+ nano := uint32(now.Nanosecond()) &^ whitenerMask
binary.BigEndian.PutUint64(tai64n[:], secs)
binary.BigEndian.PutUint32(tai64n[8:], nano)
return tai64n