Skip to content

Commit

Permalink
Fix for default Epoch to use monotonic clock
Browse files Browse the repository at this point in the history
  • Loading branch information
nishaad78 committed Apr 10, 2019
1 parent 2562822 commit ff06ed8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import (
)

var (
curTime = time.Now()
// Epoch is set to the twitter snowflake epoch of Nov 04 2010 01:42:54 UTC
// You may customize this to set a different epoch for your application.
Epoch = time.Date(2010, time.November, 4, 1, 42, 54, 0, time.UTC)
// Note: add time.Duration to time.Now() to make sure we use the monotonic clock if available.
Epoch = curTime.Add(time.Date(2010, time.November, 4, 1, 42, 54, 0, time.UTC).Sub(curTime))

// Number of bits to use for Node
// Remember, you have a total 22 bits to share between Node/Step
Expand Down

0 comments on commit ff06ed8

Please sign in to comment.