Vara's library for managing time.
local chrono = require("@vara/chrono")
local timestamp = chrono.Now()
print(`ISO8601: {timestamp:ToISO8601()}`)
print(`RFC2822: {timestamp:ToRFC2822()}`)
print(`humanised: {timestamp:Humanise()}`)
print(`中国: {timestamp:ToZH()}`)
print(`Apache: {timestamp:ToApacheLog()}`)
Danger
functions relating to timezones only work on windows, timezones for unix systems have not been implemented yet
functions
Now -> DateTime
Gets the current date and time according adjusted to the local timezone.
FromUnix -> DateTime
chrono.FromUnix(unixTime : number) : DateTime
Converts a unix timestamp into a DateTime.
FromUniversal -> DateTime
chrono.FromUniversal(params : DateTimeParameters) : DateTime
Constructs a DateTime using a table of parameters at UTC+00.
FromLocal -> DateTime
chrono.FromLocal(params : DateTimeParameters) : DateTime
Constructs a DateTime using a table of parameters in the local timezone.
TimezoneOffset -> number
chrono.TimezoneOffset() : number
returns the current timezone offset in hours.
types
DateTimeParameters
type DateTimeParameters = {
Year : number,
Month : number,
Day : number,
Hour : number,
Minute : number,
Second : number,
Millisecond : number?,
}