From: Michael Tremer Date: Mon, 8 Apr 2024 10:24:21 +0000 (+0000) Subject: lua: Add method to access database creation time X-Git-Tag: 0.9.18~62 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd1087fa28665c3348529d91a3e47f5ad491b5ab;p=location%2Flibloc.git lua: Add method to access database creation time Signed-off-by: Michael Tremer --- diff --git a/src/lua/database.c b/src/lua/database.c index 7b6c5bf..fcbbad0 100644 --- a/src/lua/database.c +++ b/src/lua/database.c @@ -86,6 +86,20 @@ static int Database_gc(lua_State* L) { return 0; } +// Created At + +static int Database_created_at(lua_State* L) { + Database* self = luaL_checkdatabase(L, 1); + + // Fetch the time + time_t created_at = loc_database_created_at(self->db); + + // Push the time onto the stack + lua_pushnumber(L, created_at); + + return 1; +} + // Description static int Database_get_description(lua_State* L) { @@ -287,6 +301,7 @@ static int Database_list_networks(lua_State* L) { } static const struct luaL_Reg database_functions[] = { + { "created_at", Database_created_at }, { "get_as", Database_get_as }, { "get_description", Database_get_description }, { "get_country", Database_get_country },