mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
fix(server/cron): getTimeUnit corrections
Consistency between range and lists. Use different time comparisons for minute units.
This commit is contained in:
@@ -65,9 +65,15 @@ local function getTimeUnit(value, unit)
|
|||||||
local min, max = string.strsplit('-', range)
|
local min, max = string.strsplit('-', range)
|
||||||
min, max = tonumber(min, 10), tonumber(max, 10)
|
min, max = tonumber(min, 10), tonumber(max, 10)
|
||||||
|
|
||||||
if currentTime >= min and currentTime <= max then return currentTime end
|
if unit == 'min' then
|
||||||
|
if currentTime >= max then
|
||||||
|
return min + unitMax
|
||||||
|
end
|
||||||
|
elseif currentTime > max then
|
||||||
|
return min + unitMax
|
||||||
|
end
|
||||||
|
|
||||||
return min + unitMax
|
return currentTime < min and min or currentTime
|
||||||
end
|
end
|
||||||
|
|
||||||
local list = string.match(value, '%d+,%d+')
|
local list = string.match(value, '%d+,%d+')
|
||||||
@@ -77,7 +83,11 @@ local function getTimeUnit(value, unit)
|
|||||||
listValue = tonumber(listValue)
|
listValue = tonumber(listValue)
|
||||||
|
|
||||||
-- e.g. if current time is less than in the expression 0,10,20,45 * * * *
|
-- e.g. if current time is less than in the expression 0,10,20,45 * * * *
|
||||||
if listValue >= currentTime then
|
if unit == 'min' then
|
||||||
|
if currentTime < listValue then
|
||||||
|
return listValue
|
||||||
|
end
|
||||||
|
elseif currentTime <= listValue then
|
||||||
return listValue
|
return listValue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -90,6 +100,10 @@ local function getTimeUnit(value, unit)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if value then
|
if value then
|
||||||
|
if unit == 'min' then
|
||||||
|
return value <= currentTime and value + unitMax or value
|
||||||
|
end
|
||||||
|
|
||||||
return value < currentTime and value + unitMax or value
|
return value < currentTime and value + unitMax or value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user