blob: d0d1432eb52244018446ddd0a290059b85eae7e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package main
import (
"encoding/binary"
"time"
)
const (
TAI64NBase = uint64(4611686018427387914)
TAI64NSize = 12
)
type TAI64N [TAI64NSize]byte
func Timestamp() TAI64N {
var tai64n TAI64N
now := time.Now()
secs := TAI64NBase + uint64(now.Unix())
nano := uint32(now.UnixNano())
binary.BigEndian.PutUint64(tai64n[:], secs)
binary.BigEndian.PutUint32(tai64n[8:], nano)
return tai64n
}
|