Skip to content

Commit fe1e623

Browse files
committed
added more detail to comment
1 parent 2373503 commit fe1e623

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

uuid.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ func TimestampFromV7(u UUID) (Timestamp, error) {
143143
(int64(u[4]) << 8) |
144144
int64(u[5])
145145

146-
// convert to format expected by Timestamp
146+
// UUIDv7 stores MS since 1979-01-01 00:00:00, but the Timestamp
147+
// type stores 100-nanosecond increments since 1582-10-15 00:00:00.
148+
// This conversion multiplies ms by 10,000 to get 100-ns chunks and adds
149+
// the difference between October 1582 and January 1979.
147150
tsNanos := epochStart + (t * _100nsPerMillisecond)
148151
return Timestamp(tsNanos), nil
149152
}

0 commit comments

Comments
 (0)