Skip to content

Instantly share code, notes, and snippets.

@Gethe
Created October 14, 2020 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gethe/8fb2fdd5886aa17dfb5a2702aeb87f04 to your computer and use it in GitHub Desktop.
Save Gethe/8fb2fdd5886aa17dfb5a2702aeb87f04 to your computer and use it in GitHub Desktop.
GetCooldownLeft
--[[
Returns the true cooldown of an ability or item, correcting for https://github.com/Stanzilla/WoWUIBugs/issues/47
Credit to Eliote and Arkoniel in the WoW Addons discord
]]
local function GetCooldownLeft(start, duration)
if start < GetTime() then
local cdEndTime = start + duration
local cdLeftDuration = cdEndTime - GetTime()
return cdLeftDuration
end
local time = time()
local startupTime = time - GetTime()
local cdTime = (2 ^ 32) / 1000 - start
local cdStartTime = startupTime - cdTime
local cdEndTime = cdStartTime + duration
local cdLeftDuration = cdEndTime - time
return cdLeftDuration
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment