From: Vsevolod Stakhov Date: Tue, 21 Aug 2018 11:36:58 +0000 (+0100) Subject: [Minor] Add time to the selectors spec X-Git-Tag: 1.8.0~231 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fec55830a7ebf7030d801a883743da84a05eea75;p=thirdparty%2Frspamd.git [Minor] Add time to the selectors spec --- 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 }