The math might be a bit sketchy and long winded to show the "what" of it so test it but something like:
I don't know the event so I'm assuming the event is runs every 1.5 hours of the day and the start time (21:00) is the "known" time one of the events happens each day in that region (EU). If it's something else like the event only runs from 21:00 to 24:00 then this is not what you're looking for.
Lua Code:
local Backdrop = {
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
}
local frame_x = 0
local frame_y = -200
f = CreateFrame("Button", "ZAMROTimer", UIParent, "BackdropTemplate")
f:SetWidth(255)
f:SetHeight(20)
f:SetBackdrop(Backdrop)
f.text = f:CreateFontString(nil,"OVERLAY","GameTooltipText")
f.text:SetTextHeight(15)
f.text:SetPoint("CENTER")
f:SetClampedToScreen(true)
f:SetPoint("CENTER",UIParent,"CENTER",frame_x,frame_y)
f:EnableMouse(true)
f:SetMovable(true)
f:RegisterForDrag("LeftButton")
f:RegisterForClicks("AnyUp")
f:Show()
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnDragStart",function(this)
this:StartMoving()
end)
f:SetScript("OnDragStop",function(this)
this:StopMovingOrSizing()
frame_x,frame_y = this:GetCenter()
frame_x = frame_x - GetScreenWidth() / 2
frame_y = frame_y - GetScreenHeight() / 2
this:ClearAllPoints()
this:SetPoint("CENTER",UIParent,"CENTER",frame_x,frame_y)
end)
local function printTime(timetotrun)
local hideSeconds = timetotrun >= 120
f.text:SetText(format("Next update in: %s", SecondsToTime(timetotrun, hideSeconds)))
end
local communityFeastTime = {
["EU"] = 75600, -- 21:00 in seconds ie. (21 * 60 * 60)
}
local startTime = communityFeastTime.EU -- start time from the table
local t = date("*t", time()) -- the time now
local timeToSeconds = ((t.hour * 60) * 60) + (t.min * 60) + t.sec -- convert time now to seconds
local timeToEvent = (startTime - timeToSeconds) % 5400 -- remaining time before next event starts
local timeToRun = timeToEvent -- set the ticker timer to time to next event
local ticker = C_Timer.NewTicker(1, function()
if timeToRun > 0 then
timeToRun = timeToRun - 1
printTime(timeToRun)
return
end
timeToRun = 5400 -- reset ticker timer to 90 mins
printTime(timeToRun)
-- do whatever after 1 hour 30
end)
printTime(timeToRun)