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 not hour then return end
if minute >= 60 then if minute >= maxUnits.min then
minute = 0 if not self.hour then
hour += 1 hour += math.floor(minute / maxUnits.min)
end
minute = minute % maxUnits.min
end 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({ return os.time({
min = minute, min = minute,
@@ -157,7 +166,7 @@ function OxTask:getNextTime()
}) })
end 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 ---@return number
function OxTask:getAbsoluteNextTime() function OxTask:getAbsoluteNextTime()
local minute = getTimeUnit(self.minute, 'min') local minute = getTimeUnit(self.minute, 'min')