fix(server/cron): more scheduling woes

Schedule next-day tasks.
Some logic improvements and breaking changes from 8488dec.
This commit is contained in:
Linden
2023-08-01 17:39:21 +10:00
parent 9d98b9aada
commit 45362017c6

View File

@@ -141,12 +141,21 @@ function OxTask:getNextTime()
if not hour then return end
if minute >= 60 then
minute = 0
hour += 1
if minute >= maxUnits.min then
if not self.hour then
hour += math.floor(minute / maxUnits.min)
end
minute = minute % maxUnits.min
end
if hour >= 24 and day then return end
if hour >= maxUnits.hour and day then
if not self.day then
day += math.floor(hour / maxUnits.hour)
end
hour = hour % maxUnits.hour
end
return os.time({
min = minute,
@@ -157,7 +166,7 @@ function OxTask:getNextTime()
})
end
-- Get timestamp for next time to run task at any day.
---Get timestamp for next time to run task at any day.
---@return number
function OxTask:getAbsoluteNextTime()
local minute = getTimeUnit(self.minute, 'min')