* Millisecond precision * formatting * Update util.go * remove unnecessary int64 * Add unit test for SnowflakeTimestamp Co-authored-by: NANI <nani@ksoft.si> Co-authored-by: Carson Hoffman <c@rsonhoffman.com>
21 lines
510 B
Go
21 lines
510 B
Go
package discordgo
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestSnowflakeTimestamp(t *testing.T) {
|
|
// #discordgo channel ID :)
|
|
id := "155361364909621248"
|
|
parsedTimestamp, err := SnowflakeTimestamp(id)
|
|
|
|
if err != nil {
|
|
t.Errorf("returned error incorrect: got %v, want nil", err)
|
|
}
|
|
|
|
correctTimestamp := time.Date(2016, time.March, 4, 17, 10, 35, 869*1000000, time.UTC)
|
|
if !parsedTimestamp.Equal(correctTimestamp) {
|
|
t.Errorf("parsed time incorrect: got %v, want %v", parsedTimestamp, correctTimestamp)
|
|
}
|
|
}
|