MINOR: hlua/event_hdl: timestamp for events
'when' optional argument is provided to lua event handlers.
It is an integer representing the number of seconds elapsed since Epoch
and may be used in conjunction with lua `os.date()` function to provide
a custom format string.
diff --git a/doc/lua-api/index.rst b/doc/lua-api/index.rst
index 1bb4997..ee30b73 100644
--- a/doc/lua-api/index.rst
+++ b/doc/lua-api/index.rst
@@ -942,12 +942,16 @@
.. code-block:: lua
- function(event, event_data, sub)
+ function(event, event_data, sub, when)
..
* **event** (*string*): the event type (one of the **event_types** you specified when subscribing)
* **event_data**: specific to each event family (For **SERVER** family, a :ref:`server_event_class` object)
* **sub**: class to manage the subscription from within the event (a :ref:`event_sub_class` object)
+ * **when**: timestamp corresponding to the date when the event was generated.
+ It is an integer representing the number of seconds elapsed since Epoch.
+ It may be provided as optional argument to `os.date()` lua function to
+ convert it to a string according to a given format string.
.. Warning::
The callback function will only be scheduled on the very same thread that
diff --git a/src/hlua.c b/src/hlua.c
index a20ab03..5c29bc5 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -9087,6 +9087,10 @@
/* sub mgmt */
hlua->nargs += 1;
hlua_fcn_new_event_sub(hlua->T, hlua_sub->sub);
+
+ /* when? */
+ hlua->nargs += 1;
+ lua_pushinteger(hlua->T, e->when.tv_sec);
}
/* events runner: if there's an ongoing hlua event handling process, finish it