Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion id.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,13 @@ func New() ID {
return NewWithTime(time.Now())
}

// NewWithTime generates a globally unique ID with the passed in time
// NewWithTime generates a globally unique ID with the passed in time.
//
// The XID format stores the timestamp in 4 bytes, so it can only represent
// times whose Unix seconds fit in a uint32. Times before 1970-01-01 or
// after 2106-02-07 06:28:15 UTC silently wrap when encoded; callers
// generating IDs from arbitrary user-supplied times should clamp or
// reject those values themselves.
func NewWithTime(t time.Time) ID {
var id ID
// Timestamp, 4 bytes, big endian
Expand Down