From a32c8dded956cf56eaaced12ec0a56d1dc956e01 Mon Sep 17 00:00:00 2001 From: shagu Date: Mon, 6 Dec 2021 14:40:07 +0100 Subject: [PATCH] helpers: move timeconvert function to helpers --- helpers.lua | 20 ++++++++++++++++++++ mods/target-debufftimer.lua | 20 +------------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/helpers.lua b/helpers.lua index 24be1f1..2de5398 100644 --- a/helpers.lua +++ b/helpers.lua @@ -253,6 +253,26 @@ ShaguTweaks.Abbreviate = function(number, eachk) return number end +ShaguTweaks.TimeConvert = function(remaining) + local color = "|cffffffff" + + if remaining < 5 then + color = "|cffff5555" + elseif remaining < 10 then + color = "|cffffff55" + end + + if remaining < 60 then + return color..ceil(remaining) + elseif remaining < 3600 then + return color..ceil(remaining/60).."m" + elseif remaining < 43200 then + return color..ceil(remaining/3600).."h" + else + return color..ceil(remaining/43200).."d" + end +end + -- http://lua-users.org/wiki/SortedIteration local function __genOrderedIndex( t ) local orderedIndex = {} diff --git a/mods/target-debufftimer.lua b/mods/target-debufftimer.lua index c761f99..6f3ac78 100644 --- a/mods/target-debufftimer.lua +++ b/mods/target-debufftimer.lua @@ -10,25 +10,7 @@ local module = ShaguTweaks:register({ local libdebuff = ShaguTweaks.libdebuff local UnitDebuff = libdebuff and libdebuff.UnitDebuff - -local function TimeConvert(remaining) - local color = "|cffffffff" - if remaining < 5 then - color = "|cffff5555" - elseif remaining < 10 then - color = "|cffffff55" - end - - if remaining < 60 then - return color..ceil(remaining) - elseif remaining < 3600 then - return color..ceil(remaining/60).."M" - elseif remaining < 43200 then - return color..ceil(remaining/3600).."H" - else - return color..ceil(remaining/43200).."D" - end -end +local TimeConvert = ShaguTweaks.TimeConvert local function CreateTextCooldown(cooldown) if cooldown.readable then return end