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);
}
發佈了61 篇原創文章 · 獲贊 5 · 訪問量 37萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章