util

package
v0.0.0-...-f3b67d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2025 License: ISC Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// IsTwitter toggles which epoch to use
	IsTwitter = false

	// TwitterEpoch is set to the Twitter snowflake epoch of Nov 04 2010 01:42:54 UTC in milliseconds
	// Docs: https://github.com/twitter-archive/snowflake/blob/b3f6a3c6ca8e1b6847baa6ff42bf72201e2c2231/src/main/scala/com/twitter/service/snowflake/IdWorker.scala#L25
	TwitterEpoch int64 = 1288834974657

	// DiscordEpoch is set to the Discord snowflake epoch of Jan 01 2015 00:00:00 UTC in milliseconds
	// Docs: https://discord.com/developers/docs/reference#snowflakes-snowflake-id-format-structure-left-to-right
	DiscordEpoch int64 = 1420070400000
)

Functions

This section is empty.

Types

type DiscordFormat

type DiscordFormat int64

DiscordFormat defaults to DiscordFormatShortDateTime Docs: https://discord.com/developers/docs/reference#message-formatting-timestamp-styles

const (
	DiscordFormatDefault DiscordFormat = iota
	DiscordFormatShortTime
	DiscordFormatLongTime
	DiscordFormatShortDate
	DiscordFormatLongDate
	DiscordFormatShortDateTime
	DiscordFormatLongDateTime
	DiscordFormatRelative
)

func (DiscordFormat) String

func (f DiscordFormat) String() string

type Snowflake

type Snowflake int64

func (Snowflake) UnixMilli

func (t Snowflake) UnixMilli() int64

type SnowflakeTime

type SnowflakeTime struct {
	time.Time
}

func NewSnowflake

func NewSnowflake(snowflake int64) SnowflakeTime

func (SnowflakeTime) FormatPretty

func (t SnowflakeTime) FormatPretty() string

func (SnowflakeTime) FormatSnowflake

func (t SnowflakeTime) FormatSnowflake(s string) string

func (SnowflakeTime) FormatTimestamp

func (t SnowflakeTime) FormatTimestamp(f DiscordFormat) string

func (SnowflakeTime) FormatUnix

func (t SnowflakeTime) FormatUnix() string

func (SnowflakeTime) FormatUnixSeconds

func (t SnowflakeTime) FormatUnixSeconds() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL