mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
fix(server/cron): getTimeUnit early return and +1 to minute
This commit is contained in:
@@ -41,6 +41,11 @@ end
|
|||||||
---@return string | number | false | nil
|
---@return string | number | false | nil
|
||||||
local function getTimeUnit(value, unit)
|
local function getTimeUnit(value, unit)
|
||||||
local currentTime = currentDate[unit]
|
local currentTime = currentDate[unit]
|
||||||
|
|
||||||
|
if not value then
|
||||||
|
return unit == 'min' and currentTime + 1 or currentTime
|
||||||
|
end
|
||||||
|
|
||||||
local unitMax = maxUnits[unit]
|
local unitMax = maxUnits[unit]
|
||||||
|
|
||||||
if type(value) == 'string' then
|
if type(value) == 'string' then
|
||||||
@@ -99,15 +104,11 @@ local function getTimeUnit(value, unit)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if value then
|
if unit == 'min' then
|
||||||
if unit == 'min' then
|
return value <= currentTime and value + unitMax or value
|
||||||
return value <= currentTime and value + unitMax or value
|
|
||||||
end
|
|
||||||
|
|
||||||
return value < currentTime and value + unitMax or value
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return currentTime
|
return value < currentTime and value + unitMax or value
|
||||||
end
|
end
|
||||||
|
|
||||||
---Get a timestamp for the next time to run the task today.
|
---Get a timestamp for the next time to run the task today.
|
||||||
|
|||||||
Reference in New Issue
Block a user