From 14ebac44d9e9fcb6de13de8466ca7df12bc1ea03 Mon Sep 17 00:00:00 2001 From: Timo Smit Date: Thu, 17 Jan 2019 18:54:59 +0100 Subject: [PATCH] Fixed util.getTimeFromString not processing a single number as seconds --- luascripts/wolfadmin/util/util.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/luascripts/wolfadmin/util/util.lua b/luascripts/wolfadmin/util/util.lua index 30f7f6c..ae190df 100644 --- a/luascripts/wolfadmin/util/util.lua +++ b/luascripts/wolfadmin/util/util.lua @@ -139,12 +139,14 @@ function util.getAreaName(areaId) end function util.getTimeFromString(str) + if tonumber(str) then return tonumber(str) end + local amount, unit = string.match(str, "^([0-9]+)([smhdwy])$") - + if not (amount and unit) then return nil end amount = math.floor(amount) - + local multiplier = { ["s"] = function(a) return a end, ["m"] = function(a) return a * 60 end, @@ -153,7 +155,7 @@ function util.getTimeFromString(str) ["w"] = function(a) return a * 60 * 60 * 24 * 7 end, ["y"] = function(a) return a * 60 * 60 * 24 * 365 end } - + return multiplier[unit](amount) end