# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1654097237 -7200
# Node ID 0684506c99d3b27372029459a67ab91eea0eae0d
# Parent  cfdc8cca64d369fefedd10e94312e5ce97019976
mod_admin_shell: Include last (mod_cron) task run time in module:info()

Don't think this is otherwise shown anywhere outside of debug logs

diff -r cfdc8cca64d3 -r 0684506c99d3 plugins/mod_admin_shell.lua
--- a/plugins/mod_admin_shell.lua	Wed Jun 01 13:59:00 2022 +0200
+++ b/plugins/mod_admin_shell.lua	Wed Jun 01 17:27:17 2022 +0200
@@ -496,6 +496,16 @@
 
 	local function item_name(item) return item.name; end
 
+	local function task_timefmt(t)
+		if not t then
+			return "no last run time"
+		elseif os.difftime(os.time(), t) < 86400 then
+			return os.date("last run today at %H:%M", t);
+		else
+			return os.date("last run %A at %H:%M", t);
+		end
+	end
+
 	local friendly_descriptions = {
 		["adhoc-provider"] = "Ad-hoc commands",
 		["auth-provider"] = "Authentication provider",
@@ -528,7 +538,7 @@
 		["metric"] = function(item)
 			return ("%s (%s%s)%s"):format(item.name, suf(item.mf.unit, " "), item.mf.type_, pre(": ", item.mf.description));
 		end,
-		["task"] = function (item) return string.format("%s (%s)", item.name or item.id, item.when); end
+		["task"] = function (item) return string.format("%s (%s, %s)", item.name or item.id, item.when, task_timefmt(item.last)); end
 	};
 
 	for host in hosts do