MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / os_time

Function os_time

Source/Misc/lua/src/lua.c:13604–13626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13602
13603
13604static int os_time (lua_State *L) {
13605time_t t;
13606if (lua_isnoneornil(L, 1)) /* called without args? */
13607t = time(NULL); /* get current time */
13608else {
13609struct tm ts;
13610luaL_checktype(L, 1, LUA_TTABLE);
13611lua_settop(L, 1); /* make sure table is at the top */
13612ts.tm_sec = getfield(L, "sec", 0);
13613ts.tm_min = getfield(L, "min", 0);
13614ts.tm_hour = getfield(L, "hour", 12);
13615ts.tm_mday = getfield(L, "day", -1);
13616ts.tm_mon = getfield(L, "month", -1) - 1;
13617ts.tm_year = getfield(L, "year", -1) - 1900;
13618ts.tm_isdst = getboolfield(L, "isdst");
13619t = mktime(&ts);
13620}
13621if (t == (time_t)(-1))
13622lua_pushnil(L);
13623else
13624lua_pushnumber(L, (lua_Number)t);
13625return 1;
13626}
13627
13628
13629static 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
lua_pushnilFunction · 0.85
lua_pushnumberFunction · 0.85

Tested by

no test coverage detected