Here's some resources related to date and time handling in Lua.
- [os.time] - gets the system time. According to the reference manual, 'The returned value is a number, whose meaning depends on your system. In POSIX, Windows, and some other systems, this number counts the number of seconds since some given start time (the "epoch"). In other systems, the meaning is not specified, and the number returned by time can be used only as an argument to [date] and [difftime].'
- [os.clock] - gets the approximate number of seconds of CPU time used by the program. This function is implemented in terms of the ANSI C
clock
[1] function, and the precise meaning of this value is implementation specific. For example, on Linux, clock
gives "CPU time" [2][3], which only counts the time in which the process is actively using the CPU and does not count time executing other processes or waiting for I/O. CPU time may be less than the real time ("wall clock time"). On Windows, clock
counts real (wall clock) time since the start of the process [4]. On Windows and Linux, the resolution on clock
is on the order of milliseconds, which is more precise than the time
function, but on other systems it may be only one second resolution. The clock
value will also wrap around on overflow, depending on the size of the data type used to represent clock_t
. Sometimes this function is more useful than os.time
for benchmarking: local clock = os.clock; local t1 = clock(); dosomething(); local dt = clock() - t1
.
- HiResTimer - implementation of higher resolution timers (platform-specific).
- [os.date] - Returns a string or a table containing date and time, formatted according to the given string format.
- TimeZone - portably returns a timezone string in the form +hhmm or -hhmm.
- [LuaDate] - Pure Lua date and time module for Lua 5.0/5.1 featuring date and time string parsing, time addition and subtraction, time span calculation, support for ISO 8601 Dates, local time support, and strftime-like formatting.
- [Time] (LuaJIT 2.0) - Pure LuaJIT library for the manipulation of dates and periods according to the Gregorian calendar, i.e. the internationally accepted calendar for most uses. Time operations are supported, microsecond precision.
- SleepFunction - functions to pause a program for a certain duration
- [luaposix] has some date/time functions (POSIX, C wrappers) [lposix.c]. Functions: gettimeofday(), time(), localtime([time]), gmtime([time]), lock_getres([clockid]), clock_gettime([clockid]), strftime(format, [time]), (tm, next = strptime(s, format)), ctime = mktime(tm).
- [lzmq-timer] - Provide platform independent monotonic and absolute timers.
RecentChanges · preferences
edit · history
Last edited July 26, 2016 7:44 am GMT (diff)