👼 Default start time change to 2008-11-10 23:00:00 UTC

This commit is contained in:
Godruoyi
2021-04-15 14:15:58 +08:00
parent 0bcd35685b
commit 39b1eea4da
2 changed files with 4 additions and 3 deletions

View File

@@ -25,13 +25,14 @@ const (
// AtomicResolver : base sync/atomic (by default).
type SequenceResolver func(ms int64) (uint16, error)
// default start time is 2014-09-01 00:00:00UTC
// default start time is 2008-11-10 23:00:00 UTC, why ? In the playground the time begins at 2009-11-10 23:00:00 UTC.
// It's can run on golang playground.
// default machineID is 0
// default resolver is AtomicResolver
var (
resolver SequenceResolver
machineID = 0
startTime = time.Date(2014, 9, 1, 0, 0, 0, 0, time.UTC)
startTime = time.Date(2008, 11, 10, 23, 0, 0, 0, time.UTC)
)
// ID use ID to generate snowflake id and it will ignore error. if you want error info, you need use NextID method.

View File

@@ -55,7 +55,7 @@ func TestSetStartTime(t *testing.T) {
})
t.Run("Default start time", func(tt *testing.T) {
defaultTime := time.Date(2014, 9, 1, 0, 0, 0, 0, time.UTC)
defaultTime := time.Date(2008, 11, 10, 23, 0, 0, 0, time.UTC)
defaultNano := defaultTime.UTC().UnixNano() / 1e6
sid := snowflake.ParseID(snowflake.ID())