mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
fix(server/cron): invalid step return for indivisible values
Was reliant on some previously removed hacky-logic in scheduleTask. Return value + max and rely on getNextTime/os.time to handle overflow.
This commit is contained in:
@@ -52,16 +52,15 @@ local function getTimeUnit(value, unit)
|
|||||||
local stepValue = string.match(value, '*/(%d+)')
|
local stepValue = string.match(value, '*/(%d+)')
|
||||||
|
|
||||||
if stepValue then
|
if stepValue then
|
||||||
|
-- */10 * * * * is equal to a list of 0,10,20,30,40,50
|
||||||
|
-- best suited to factors of unitMax (excluding the highest and lowest numbers)
|
||||||
|
-- i.e. for minutes - 2, 3, 4, 5, 6, 10, 12, 15, 20, 30
|
||||||
for i = currentTime + 1, unitMax do
|
for i = currentTime + 1, unitMax do
|
||||||
-- return the current minute if it is divisible by the stepvalue
|
-- if i is divisible by stepValue
|
||||||
-- i.e. */10 * * * * is equal to a list of 0,10,20,30,40,50
|
if i % stepValue == 0 then return i end
|
||||||
-- best suited to numbers evenly divided by unitMax
|
|
||||||
if i % stepValue == 0 then
|
|
||||||
return i
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return 0
|
return stepValue + unitMax
|
||||||
end
|
end
|
||||||
|
|
||||||
local range = string.match(value, '%d+-%d+')
|
local range = string.match(value, '%d+-%d+')
|
||||||
|
|||||||
Reference in New Issue
Block a user