mirror of
https://github.com/etlegacy/wolfadmin.git
synced 2024-11-25 13:41:21 +00:00
Fixed util.getTimeFromString not processing a single number as seconds
This commit is contained in:
parent
adb469a29f
commit
14ebac44d9
1 changed files with 5 additions and 3 deletions
|
@ -139,12 +139,14 @@ function util.getAreaName(areaId)
|
||||||
end
|
end
|
||||||
|
|
||||||
function util.getTimeFromString(str)
|
function util.getTimeFromString(str)
|
||||||
|
if tonumber(str) then return tonumber(str) end
|
||||||
|
|
||||||
local amount, unit = string.match(str, "^([0-9]+)([smhdwy])$")
|
local amount, unit = string.match(str, "^([0-9]+)([smhdwy])$")
|
||||||
|
|
||||||
if not (amount and unit) then return nil end
|
if not (amount and unit) then return nil end
|
||||||
|
|
||||||
amount = math.floor(amount)
|
amount = math.floor(amount)
|
||||||
|
|
||||||
local multiplier = {
|
local multiplier = {
|
||||||
["s"] = function(a) return a end,
|
["s"] = function(a) return a end,
|
||||||
["m"] = function(a) return a * 60 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,
|
["w"] = function(a) return a * 60 * 60 * 24 * 7 end,
|
||||||
["y"] = function(a) return a * 60 * 60 * 24 * 365 end
|
["y"] = function(a) return a * 60 * 60 * 24 * 365 end
|
||||||
}
|
}
|
||||||
|
|
||||||
return multiplier[unit](amount)
|
return multiplier[unit](amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue