Skip to content

Commit

Permalink
added more detail to comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kohenkatz committed Feb 10, 2025
1 parent 893c323 commit b6353ae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ func TimestampFromV7(u UUID) (Timestamp, error) {
(int64(u[4]) << 8) |
int64(u[5])

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

0 comments on commit b6353ae

Please sign in to comment.