MCPcopy
hub / github.com/google/uuid / getTime

Function getTime

time.go:51–72  ·  view source on GitHub ↗
(customTime *time.Time)

Source from the content-addressed store, hash-verified

49}
50
51func getTime(customTime *time.Time) (Time, uint16, error) {
52 var t time.Time
53 if customTime == nil { // When not provided, use the current time
54 t = timeNow()
55 } else {
56 t = *customTime
57 }
58
59 // If we don't have a clock sequence already, set one.
60 if clockSeq == 0 {
61 setClockSequence(-1)
62 }
63 now := uint64(t.UnixNano()/100) + g1582ns100
64
65 // If time has gone backwards with this clock sequence then we
66 // increment the clock sequence
67 if now <= lasttime {
68 clockSeq = ((clockSeq + 1) & 0x3fff) | 0x8000
69 }
70 lasttime = now
71 return Time(now), clockSeq, nil
72}
73
74// ClockSequence returns the current clock sequence, generating one if not
75// already set. The clock sequence is only used for Version 1 UUIDs.

Callers 3

NewV6WithTimeFunction · 0.85
GetTimeFunction · 0.85
TestGetTimeFunction · 0.85

Calls 2

setClockSequenceFunction · 0.85
TimeTypeAlias · 0.85

Tested by 1

TestGetTimeFunction · 0.68