fix(cron): fix unused args

This commit is contained in:
Thekuca
2023-08-17 00:07:39 +02:00
committed by GitHub
parent 608fb34550
commit 48c9662377
+6 -8
View File
@@ -13,20 +13,18 @@ function GetUnixTimestamp()
return os.time()
end
function OnTime(h, m)
local currentTimestamp = GetUnixTimestamp()
function OnTime(time)
for i = 1, #Jobs, 1 do
local scheduledTimestamp = os.time({
hour = Jobs[i].h,
minute = Jobs[i].m,
second = 0, -- Assuming tasks run at the start of the minute
day = os.date('%d', currentTimestamp),
month = os.date('%m', currentTimestamp),
year = os.date('%Y', currentTimestamp)
day = os.date('%d', time),
month = os.date('%m', time),
year = os.date('%Y', time)
})
if currentTimestamp >= scheduledTimestamp and (not LastTime or LastTime < scheduledTimestamp) then
if time >= scheduledTimestamp and (not LastTime or LastTime < scheduledTimestamp) then
Jobs[i].cb(Jobs[i].h, Jobs[i].m)
end
end
@@ -36,7 +34,7 @@ function Tick()
local time = GetUnixTimestamp()
if not LastTime or os.date('%M', time) ~= os.date('%M', LastTime) then
OnTime(os.date('%H', time), os.date('%M', time))
OnTime(time)
LastTime = time
end