struct tm转time_t

int status = luaL_dofile(L,"setting.ini");
if (!status)
{
struct tm dt;
lua_getglobal(L, "year");dt.tm_year=lua_tointeger(L,-1);
lua_getglobal(L, "mon");dt.tm_mon=lua_tointeger(L,-1);
lua_getglobal(L, "day");dt.tm_mday=lua_tointeger(L,-1);
lua_getglobal(L, "hour");dt.tm_hour=lua_tointeger(L,-1);
lua_getglobal(L, "min");dt.tm_min=lua_tointeger(L,-1);
lua_getglobal(L, "sec");dt.tm_sec=lua_tointeger(L,-1);


dt.tm_year -= 1900; //years since 1900
dt.tm_mon -= 1; //month of year - [0,11]
dt.tm_isdst = 0;


maintenanceTime = mktime(&dt);
}

你可能感兴趣的:(struct tm转time_t)