From becc29bcead935c109686de0ce083cc257180ec0 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Sun, 6 Aug 2023 17:14:32 +1000 Subject: [PATCH] fix(server/cron): getTimeUnit early return and +1 to minute --- imports/cron/server.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/imports/cron/server.lua b/imports/cron/server.lua index e409f83..3861ea4 100644 --- a/imports/cron/server.lua +++ b/imports/cron/server.lua @@ -41,6 +41,11 @@ end ---@return string | number | false | nil local function getTimeUnit(value, unit) local currentTime = currentDate[unit] + + if not value then + return unit == 'min' and currentTime + 1 or currentTime + end + local unitMax = maxUnits[unit] if type(value) == 'string' then @@ -99,15 +104,11 @@ local function getTimeUnit(value, unit) return false end - if value then - if unit == 'min' then - return value <= currentTime and value + unitMax or value - end - - return value < currentTime and value + unitMax or value + if unit == 'min' then + return value <= currentTime and value + unitMax or value end - return currentTime + return value < currentTime and value + unitMax or value end ---Get a timestamp for the next time to run the task today.