Date - truemedian/Discordia GitHub Wiki
Represents a single moment in time and provides utilities for converting to and from different date and time formats. Although microsecond precision is available, most formats are implemented with only second precision.
parseISO
parseHeader
parseSnowflake
parseTable
parseTableUTC
fromISO
fromHeader
fromSnowflake
fromTable
fromTableUTC
fromSeconds
fromMilliseconds
fromMicroseconds
toString
toISO
toSnowflake
toSnowflake
toTable
toTableUTC
toSeconds
toMilliseconds
toMicroseconds
toParts
Converts an ISO 8601 string into a Unix time in seconds. For compatibility with Discord's timestamp format, microseconds are also provided as a second return value.
Name Type str string Returns: number, number
Converts an RFC 2822 string (an HTTP Date header) into a Unix time in seconds.
Name Type str string Returns: number
Converts a Discord/Twitter Snowflake ID into a Unix time in seconds. Additional decimal points may be present, though only the first 3 (milliseconds) should be considered accurate.
Name Type str string Returns: number
Interprets a Lua date table as a local time and converts it to a Unix time in seconds. Equivalent to
os.time(tbl).
Name Type str string Returns: number
Interprets a Lua date table as a UTC time and converts it to a Unix time in seconds. Equivalent to
os.time(tbl)with a correction for UTC.
Name Type str string Returns: number
Constructs a new Date object from an ISO 8601 string. Equivalent to
Date(Date.parseISO(str)).
Name Type str string Returns: Date
Constructs a new Date object from an RFC 2822 string. Equivalent to
Date(Date.parseHeader(str)).
Name Type str string Returns: Date
Constructs a new Date object from a Discord/Twitter Snowflake ID. Equivalent to
Date(Date.parseSnowflake(id)).
Name Type str string Returns: Date
Constructs a new Date object from a Lua date table interpreted as a local time. Equivalent to
Date(Date.parseTable(tbl)).
Name Type tbl table Returns: Date
Constructs a new Date object from a Lua date table interpreted as a UTC time. Equivalent to
Date(Date.parseTableUTC(tbl)).
Name Type tbl table Returns: Date
Constructs a new Date object from a Unix time in seconds.
Name Type t number Returns: Date
Constructs a new Date object from a Unix time in milliseconds.
Name Type t number Returns: Date
Constructs a new Date object from a Unix time in microseconds.
Name Type t number Returns: Date
Returns a string from this Date object in human-readable form.
Returns: string
Returns an ISO 8601 string that represents the stored date and time. If
sepandtzare both provided, then they are used as a custom separator and timezone; otherwise,Tis used for the separator and+00:00is used for the timezone, plus microseconds if available.
Name Type Optional Optional sep string x tz string x Returns: string
Returns an RFC 2822 string that represents the stored date and time.
Returns: string
Returns a synthetic Discord Snowflake ID based on the stored date and time. Note that
Date.fromSnowflake(id):toSnowflake()will most likely not return the original Snowflake.Returns: string
Returns a Lua date table that represents the stored date and time as a local time. Equivalent to
os.date('*t', s)wheresis the Unix time in seconds.Returns: table
Returns a Lua date table that represents the stored date and time as a UTC time. Equivalent to
os.date('!*t', s)wheresis the Unix time in seconds.Returns: table
Returns a Unix time in seconds that represents the stored date and time.
Returns: number
Returns a Unix time in milliseconds that represents the stored date and time.
Returns: number
Returns a Unix time in microseconds that represents the stored date and time.
Returns: number
Returns the seconds and microseconds that are stored in the date object.
Returns: number, number