added create date calculator for server.

This commit is contained in:
5elenay 2021-08-23 08:44:16 +03:00
parent 4147d56df4
commit 23077a7b70

View File

@ -1,6 +1,10 @@
package revoltgo
import "time"
import (
"time"
"github.com/oklog/ulid/v2"
)
// Server struct.
type Server struct {
@ -35,3 +39,15 @@ type SystemMessages struct {
UserKicked string `json:"user_kicker"`
UserBanned string `json:"user_banned"`
}
// Calculate creation date and edit the struct.
func (c *Server) CalculateCreationDate() error {
ulid, err := ulid.Parse(c.Id)
if err != nil {
return err
}
c.CreatedAt = time.UnixMilli(int64(ulid.Time()))
return nil
}