File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,9 @@ func (uuid UUID) Time() Time {
113
113
var t Time
114
114
switch uuid .Version () {
115
115
case 6 :
116
- time := binary .BigEndian .Uint64 (uuid [:8 ]) // Ignore uuid[6] version b0110
116
+ time := int64 (binary .BigEndian .Uint32 (uuid [0 :4 ])) << 28
117
+ time |= int64 (binary .BigEndian .Uint16 (uuid [4 :6 ])) << 12
118
+ time |= int64 (binary .BigEndian .Uint16 (uuid [6 :8 ]) & 0xfff )
117
119
t = Time (time )
118
120
case 7 :
119
121
time := binary .BigEndian .Uint64 (uuid [:8 ])
Original file line number Diff line number Diff line change @@ -39,12 +39,16 @@ func NewV6() (UUID, error) {
39
39
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40
40
*/
41
41
42
- binary .BigEndian .PutUint64 (uuid [0 :], uint64 (now ))
42
+ timeHigh := uint32 ((now >> 28 ) & 0xffffffff )
43
+ timeMid := uint16 ((now >> 12 ) & 0xffff )
44
+ timeLow := uint16 (now & 0x0fff )
45
+ timeLow |= 0x6000 // Version 6
46
+
47
+ binary .BigEndian .PutUint32 (uuid [0 :], timeHigh )
48
+ binary .BigEndian .PutUint16 (uuid [4 :], timeMid )
49
+ binary .BigEndian .PutUint16 (uuid [6 :], timeLow )
43
50
binary .BigEndian .PutUint16 (uuid [8 :], seq )
44
51
45
- uuid [6 ] = 0x60 | (uuid [6 ] & 0x0F )
46
- uuid [8 ] = 0x80 | (uuid [8 ] & 0x3F )
47
-
48
52
nodeMu .Lock ()
49
53
if nodeID == zeroID {
50
54
setNodeInterface ("" )
You can’t perform that action at this time.
0 commit comments