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