PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Sep 26 2018, 2:06 AM PST 2 min

The os library currently serves the purpose of providing information about the system time, under the UTC format. It has been heavily sandboxed from the standard Lua os library, and does not allow you to perform any system altering operations.


Functions


os.time

int os.time()

Description: Returns how many seconds have elapsed since the UNIX epoch (1 January 1970, 00:00:00), under UTC time.


os.difftime

int os.difftime(int t2, int t1)

Description: Returns the number of seconds from t1 to t1. The difference is computed assuming that t1 and t2 are correctly casted to the time_t format.


os.date

dictionary os.date(string formatString, int time)

Description: Returns a table containing the components (year, hour, etc.) of the date at the given time. The formatString can be either "*t" (for the local timezone) or "!*t" (for Coordinated Universal Time). The time parameter defaults to the current return value of os.time().

The returned dictionary contains the following data:

Field Type Description
year int An integer that describes the current year of the Current Era (ex. 2017)
month int An integer between 1 and 12 (starting from January) that describes the current month.
wday int An integer between 1 and 7 (starting from Sunday) that describes the current week day.
yday int An integer between 1 and 366 describing how many days we are into the year.
There can be 366 days if it is a leap year.
day int An integer between 1 and 31 describing the current day of the month.
hour int An integer between 1 and 24 describing the current hour of the day.
min int An integer between 0 and 59 describing the current minute of the hour.
sec int An integer between 0 and 60 describing the current second of the hour.
(60 because the function is described to indicate leap seconds, but in practice it probably doesn't).
isdst bool A boolean describing if daylight savings time is currently active.