Comparison

teal-src/plugins/mod_cron.tl @ 12000:00c57684cf20

mod_cron: Follow convention of imports at the top
author Kim Alvefur <zash@zash.se>
date Fri, 03 Dec 2021 08:57:40 +0100
parent 11995:bbd3ac65640d
child 12001:5a8c6f9a4583
comparison
equal deleted inserted replaced
11999:9d2eab56f124 12000:00c57684cf20
1 module:set_global(); 1 module:set_global();
2 2
3 local async = require "util.async"; 3 local async = require "util.async";
4 local datetime = require "util.datetime";
4 5
5 local record map_store<K,V> 6 local record map_store<K,V>
6 -- TODO move to somewhere sensible 7 -- TODO move to somewhere sensible
7 get : function (map_store<K,V>, string, K) : V 8 get : function (map_store<K,V>, string, K) : V
8 set : function (map_store<K,V>, string, K, V) 9 set : function (map_store<K,V>, string, K, V)
51 if task.last == nil then 52 if task.last == nil then
52 task.last = last_run_times:get(nil, task.id); 53 task.last = last_run_times:get(nil, task.id);
53 end 54 end
54 task.save = save_task; 55 task.save = save_task;
55 module:log("debug", "%s task %s added, last run %s", task.when, task.id, 56 module:log("debug", "%s task %s added, last run %s", task.when, task.id,
56 task.last and require"util.datetime".datetime(task.last) or "never"); 57 task.last and datetime.datetime(task.last) or "never");
57 if task.last == nil and task.when == "daily" then 58 if task.last == nil and task.when == "daily" then
58 -- initialize daily tasks to run at ~midnight UTC for now 59 -- initialize daily tasks to run at ~midnight UTC for now
59 local now = os.time(); 60 local now = os.time();
60 task.last = now - now % 86400; 61 task.last = now - now % 86400;
61 end 62 end