mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 23:16:03 +01:00
fix(server/cron): more scheduling woes
Schedule next-day tasks.
Some logic improvements and breaking changes from 8488dec.
This commit is contained in:
@@ -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
|
end
|
||||||
|
|
||||||
if hour >= 24 and day then return end
|
minute = minute % maxUnits.min
|
||||||
|
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')
|
||||||
|
|||||||
Reference in New Issue
Block a user