UNIT_AURA tells you when you gain/loose an aura (you might be waiting a while for this to fire). To update the time left on an aura you need to use an OnUpdate script (which happens every time the frame is updated ie. lots)
Lua Code:
frame.TimeToCheck = 1 -- check buff timers every second
frame:SetScript("OnUpdate", function(self, elapsed)
self.TimeToCheck = self.TimeToCheck - elapsed
if self.TimeToCheck > 0 then
return -- We haven't counted down to zero yet so do nothing
end
self.TimeToCheck = 1 -- We've waited a second so reset the timer
for i=1, 40 do
-- check your buff/debuff times
end
end)
Or a C_Timer as mentioned above but you need to check more often or at a known time rather than when a random event fires.