mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-23 19:22:03 -08:00
18 lines
368 B
Go
18 lines
368 B
Go
|
package discordgo
|
||
|
|
||
|
import (
|
||
|
"strconv"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
// SnowflakeTimestamp returns the creation time of a Snowflake ID relative to the creation of Discord.
|
||
|
func SnowflakeTimestamp(ID string) (t time.Time, err error) {
|
||
|
i, err := strconv.ParseInt(ID, 10, 64)
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
timestamp := (i >> 22) + 1420070400000
|
||
|
t = time.Unix(timestamp/1000, 0)
|
||
|
return
|
||
|
}
|