Skip to content

Commit b6353ae

Browse files
committed
added more detail to comment
1 parent 893c323 commit b6353ae

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

uuid.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ func TimestampFromV7(u UUID) (Timestamp, error) {
147147
(int64(u[4]) << 8) |
148148
int64(u[5])
149149

150-
// convert to format expected by Timestamp
150+
// UUIDv7 stores MS since 1979-01-01 00:00:00, but the Timestamp
151+
// type stores 100-nanosecond increments since 1582-10-15 00:00:00.
152+
// This conversion multiplies ms by 10,000 to get 100-ns chunks and adds
153+
// the difference between October 1582 and January 1979.
151154
tsNanos := epochStart + (t * _100nsPerMillisecond)
152155
return Timestamp(tsNanos), nil
153156
}

0 commit comments

Comments
 (0)