MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / os_time

Function os_time

extlibs/lua/src/loslib.c:344–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342
343
344static int os_time (lua_State *L) {
345 time_t t;
346 if (lua_isnoneornil(L, 1)) /* called without args? */
347 t = time(NULL); /* get current time */
348 else {
349 struct tm ts;
350 luaL_checktype(L, 1, LUA_TTABLE);
351 lua_settop(L, 1); /* make sure table is at the top */
352 ts.tm_year = getfield(L, "year", -1, 1900);
353 ts.tm_mon = getfield(L, "month", -1, 1);
354 ts.tm_mday = getfield(L, "day", -1, 0);
355 ts.tm_hour = getfield(L, "hour", 12, 0);
356 ts.tm_min = getfield(L, "min", 0, 0);
357 ts.tm_sec = getfield(L, "sec", 0, 0);
358 ts.tm_isdst = getboolfield(L, "isdst");
359 t = mktime(&ts);
360 setallfields(L, &ts); /* update fields with normalized values */
361 }
362 if (t != (time_t)(l_timet)t || t == (time_t)(-1))
363 return luaL_error(L,
364 "time result cannot be represented in this installation");
365 l_pushtime(L, t);
366 return 1;
367}
368
369
370static int os_difftime (lua_State *L) {

Callers

nothing calls this directly

Calls 6

luaL_checktypeFunction · 0.85
lua_settopFunction · 0.85
getfieldFunction · 0.85
getboolfieldFunction · 0.85
setallfieldsFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected