Diff

core/moduleapi.lua @ 12002:cbed7d8d8f35

mod_cron: Add a 'weekly' job frequency
author Kim Alvefur <zash@zash.se>
date Fri, 03 Dec 2021 09:05:41 +0100
parent 11987:4b519c575ad0
child 12095:c1d2bc6603ae
line wrap: on
line diff
--- a/core/moduleapi.lua	Fri Dec 03 09:01:09 2021 +0100
+++ b/core/moduleapi.lua	Fri Dec 03 09:05:41 2021 +0100
@@ -521,6 +521,11 @@
 	self:cron({ name = name; when = "daily"; run = fun });
 end
 
+function api:weekly(name, fun)
+	if type(name) == "function" then fun, name = name, nil; end
+	self:cron({ name = name; when = "weekly"; run = fun });
+end
+
 local path_sep = package.config:sub(1,1);
 function api:get_directory()
 	return self.resource_path or self.path and (self.path:gsub("%"..path_sep.."[^"..path_sep.."]*$", "")) or nil;