MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / os_time

Function os_time

third-party/lua-5.2.4/src/loslib.c:241–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239
240
241static int os_time (lua_State *L) {
242 time_t t;
243 if (lua_isnoneornil(L, 1)) /* called without args? */
244 t = time(NULL); /* get current time */
245 else {
246 struct tm ts;
247 luaL_checktype(L, 1, LUA_TTABLE);
248 lua_settop(L, 1); /* make sure table is at the top */
249 ts.tm_sec = getfield(L, "sec", 0);
250 ts.tm_min = getfield(L, "min", 0);
251 ts.tm_hour = getfield(L, "hour", 12);
252 ts.tm_mday = getfield(L, "day", -1);
253 ts.tm_mon = getfield(L, "month", -1) - 1;
254 ts.tm_year = getfield(L, "year", -1) - 1900;
255 ts.tm_isdst = getboolfield(L, "isdst");
256 t = mktime(&ts);
257 }
258 if (t == (time_t)(-1))
259 lua_pushnil(L);
260 else
261 lua_pushnumber(L, (lua_Number)t);
262 return 1;
263}
264
265
266static int os_difftime (lua_State *L) {

Callers

nothing calls this directly

Calls 6

luaL_checktypeFunction · 0.70
lua_settopFunction · 0.70
getfieldFunction · 0.70
getboolfieldFunction · 0.70
lua_pushnilFunction · 0.70
lua_pushnumberFunction · 0.70

Tested by

no test coverage detected