os
os
This 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.
| int os.time ( table time = UTC time ) |
|
Returns how many seconds have passed since the Unix epoch (1 January 1970, 00:00:00), under current UTC time. If provided a table formatted similarly to that returned by print(os.time()) --> 1586982482 (ran at approx. April 15th, 2020 at 1:28 PM PST)
print(os.time({
year=2020, month=4, day=15, -- Date components
hour=16, min=28, sec=0 -- Time components
})) --> 1586968080
|
| int os.difftime ( int t2, int t1 ) |
|
Returns the number of seconds from t1 to t2. The difference is computed assuming that t1 and t2 are correctly casted to the time_t format. |
| dictionary os.date ( string formatString, int time ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Formats the given
* This value can vary depending on the current locale. If the provided
|
| os.clock ( ) |
|
Returns the amount of CPU time used by Lua in seconds. This value has high precision, about 1 microsecond, and is intended for use in benchmarking. -- Record the initial time:
local startTime = os.clock()
-- Do something you want to measure the performance of:
local a, b = 0, 1
for i = 1, 5000000 do
a, b = b, a
end
-- Measure amount of time this took:
local deltaTime = os.clock() - startTime
print("Elapsed time: " .. deltaTime)
--> Elapsed time: 0.044425600033719 (actual number may vary)
|