diff --git a/src/lib_os.c b/src/lib_os.c index 7821fc1f..bf174915 100644 --- a/src/lib_os.c +++ b/src/lib_os.c @@ -243,9 +243,10 @@ LJLIB_CF(os_time) ts.tm_mon = (int)((unsigned int)getfield(L, "month", -1) - 1u); ts.tm_year = (int)((unsigned int)getfield(L, "year", -1) - 1900u); ts.tm_isdst = getboolfield(L, "isdst"); + errno = 0; t = mktime(&ts); } - if (t == (time_t)(-1)) + if (t == (time_t)(-1) && errno != 0) lua_pushnil(L); else lua_pushnumber(L, (lua_Number)t);