From c27637908d28a142bcbe8d03786d1719dbb33343 Mon Sep 17 00:00:00 2001 From: NoM0Re Date: Sun, 9 Feb 2025 15:59:35 +0100 Subject: [PATCH] from retail --- WeakAuras/Types.lua | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index b583fe5..eae6010 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -123,29 +123,39 @@ Private.unit_realm_name_types = { } local simpleFormatters = { ---[[ - AbbreviateNumbers = function(value, state) + --[[AbbreviateNumbers = function(value) + if type(value) == "string" then value = tonumber(value) end return (type(value) == "number") and AbbreviateNumbers(value) or value end, - AbbreviateLargeNumbers = function(value, state) + AbbreviateLargeNumbers = function(value) + if type(value) == "string" then value = tonumber(value) end return (type(value) == "number") and AbbreviateLargeNumbers(Round(value)) or value end, -]] + BreakUpLargeNumbers = function(value) + if type(value) == "string" then value = tonumber(value) end + return (type(value) == "number") and BreakUpLargeNumbers(value) or value + end,]] floor = function(value) + if type(value) == "string" then value = tonumber(value) end return (type(value) == "number") and floor(value) or value end, ceil = function(value) + if type(value) == "string" then value = tonumber(value) end return (type(value) == "number") and ceil(value) or value end, round = function(value) + if type(value) == "string" then value = tonumber(value) end return (type(value) == "number") and Round(value) or value end, time = { [0] = function(value) - if value > 60 then - return string.format("%i:", math.floor(value / 60)) .. string.format("%02i", value % 60) - else - return string.format("%d", value) + if type(value) == "string" then value = tonumber(value) end + if type(value) == "number" then + if value > 60 then + return string.format("%i:", math.floor(value / 60)) .. string.format("%02i", value % 60) + else + return string.format("%d", value) + end end end, -- Old Blizzard @@ -154,13 +164,20 @@ local simpleFormatters = { -- Remove the space between the value and unit return fmt:gsub(" ", ""):format(time) end, + --[[ Modern Blizzard + [2] = WeakAuras.IsRetail() and function(value) + return timeFormatter:Format(value) + end,]] -- Fixed built-in formatter [99] = function(value) - value = ceil(value) - if value > 60 then - return string.format("%i:", math.floor(value / 60)) .. string.format("%02i", value % 60) - else - return string.format("%d", value) + if type(value) == "string" then value = tonumber(value) end + if type(value) == "number" then + value = ceil(value) + if value > 60 then + return string.format("%i:", math.floor(value / 60)) .. string.format("%02i", value % 60) + else + return string.format("%d", value) + end end end, },