1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-25 01:05:10 +03:00

Fixes #1649: added getDateTime() in lua which returns current date and time

This commit is contained in:
Damjan Adamic 2014-09-20 11:23:33 +02:00
parent e4bb750c1f
commit 7497be4d28

View file

@ -113,6 +113,20 @@ static int luaGetTime(lua_State *L)
return 1;
}
static int luaGetDateTime(lua_State *L)
{
struct gtm utm;
gettime(&utm);
lua_newtable(L);
lua_pushtableinteger(L, "year", utm.tm_year+1900);
lua_pushtableinteger(L, "mon", utm.tm_mon+1);
lua_pushtableinteger(L, "day", utm.tm_mday);
lua_pushtableinteger(L, "hour", utm.tm_hour);
lua_pushtableinteger(L, "min", utm.tm_min);
lua_pushtableinteger(L, "sec", utm.tm_sec);
return 1;
}
static void luaGetValueAndPush(int src)
{
if (src >= MIXSRC_FIRST_TELEM && src <= MIXSRC_LAST_TELEM) {
@ -1379,6 +1393,7 @@ int luaGetOutputs(ScriptInputsOutputs & sid)
const luaL_Reg opentxLib[] = {
{ "getTime", luaGetTime },
{ "getDateTime", luaGetDateTime },
{ "getVersion", luaGetVersion },
{ "getGeneralSettings", luaGetGeneralSettings },
{ "getValue", luaGetValue },