summaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-21 12:36:58 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-21 12:36:58 +0100
commitfec55830a7ebf7030d801a883743da84a05eea75 (patch)
treea47cd4c73d149aa785d478b882c738fbf50bc9d2 /lualib
parent490f14afa962f4338c5c66157d873e4fad8caf77 (diff)
downloadrspamd-fec55830a7ebf7030d801a883743da84a05eea75.tar.gz
rspamd-fec55830a7ebf7030d801a883743da84a05eea75.zip
[Minor] Add time to the selectors spec
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_selectors.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua
index 096490ef8..69a20b9c4 100644
--- a/lualib/lua_selectors.lua
+++ b/lualib/lua_selectors.lua
@@ -209,6 +209,25 @@ local extractors = {
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
}
}