summaryrefslogtreecommitdiff
path: root/epan/wslua/wslua_nstime.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/wslua/wslua_nstime.c')
-rw-r--r--epan/wslua/wslua_nstime.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/epan/wslua/wslua_nstime.c b/epan/wslua/wslua_nstime.c
index e04524151d..f0a87f0595 100644
--- a/epan/wslua/wslua_nstime.c
+++ b/epan/wslua/wslua_nstime.c
@@ -30,7 +30,7 @@
#include "config.h"
#include "wslua.h"
-
+#include <wsutil/nstime.h>
/* WSLUA_CONTINUE_MODULE Pinfo */
@@ -61,6 +61,15 @@ WSLUA_METAMETHOD NSTime__call(lua_State* L) { /* Creates a NSTime object. */
WSLUA_RETURN(NSTime_new(L)); /* The new NSTime object. */
}
+WSLUA_METHOD NSTime_tonumber(lua_State* L) {
+ /* Returns a Lua number of the `NSTime` representing seconds from epoch
+ * @since 2.4.0
+ * */
+ NSTime nstime = checkNSTime(L,1);
+ lua_pushnumber(L, (lua_Number)nstime_to_sec(nstime));
+ WSLUA_RETURN(1); /* The Lua number. */
+}
+
WSLUA_METAMETHOD NSTime__tostring(lua_State* L) {
NSTime nstime = checkNSTime(L,1);
gchar *str;
@@ -174,6 +183,7 @@ WSLUA_ATTRIBUTES NSTime_attributes[] = {
WSLUA_METHODS NSTime_methods[] = {
WSLUA_CLASS_FNREG(NSTime,new),
+ WSLUA_CLASS_FNREG(NSTime,tonumber),
{ NULL, NULL }
};