Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in uuid. The time is only defined for version 1, 2, 6 and 7 UUIDs.
()
| 110 | // Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in |
| 111 | // uuid. The time is only defined for version 1, 2, 6 and 7 UUIDs. |
| 112 | func (uuid UUID) Time() Time { |
| 113 | var t Time |
| 114 | switch uuid.Version() { |
| 115 | case 6: |
| 116 | time := binary.BigEndian.Uint64(uuid[:8]) // Ignore uuid[6] version b0110 |
| 117 | t = Time(time) |
| 118 | case 7: |
| 119 | time := binary.BigEndian.Uint64(uuid[:8]) |
| 120 | t = Time((time>>16)*10000 + g1582ns100) |
| 121 | default: // forward compatible |
| 122 | time := int64(binary.BigEndian.Uint32(uuid[0:4])) |
| 123 | time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32 |
| 124 | time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48 |
| 125 | t = Time(time) |
| 126 | } |
| 127 | return t |
| 128 | } |
| 129 | |
| 130 | // ClockSequence returns the clock sequence encoded in uuid. |
| 131 | // The clock sequence is only well defined for version 1 and 2 UUIDs. |