From fec55830a7ebf7030d801a883743da84a05eea75 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 21 Aug 2018 12:36:58 +0100 Subject: [PATCH] [Minor] Add time to the selectors spec --- lualib/lua_selectors.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index 096490ef82..69a20b9c49 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -207,6 +207,25 @@ local extractors = { return tostring(hdr) end + return nil + end + }, + -- Get task date, optionally formatted + ['time'] = { + ['type'] = 'string', + ['get_value'] = function(task, _, args) + local what = args[1] or 'message' + local dt = task:get_date{format = what, gmt = true} + + if dt then + if args[2] then + -- Should be in format !xxx, as dt is in GMT + return os.date(args[2], dt) + end + + return tostring(dt) + end + return nil end } -- 2.47.3