Blizzard_TimeManager.toc sets the time manager as LoadOnDemand, so it is not loaded initially.
UIParent attempts to load it twice, early if an alarm is enabled, then a second time at PLAYER_LOGIN:
Lua Code:
function UIParent_OnEvent(self, event, ...)
...
elseif ( event == "VARIABLES_LOADED" ) then
...
if ( not TimeManagerFrame and GetCVar("timeMgrAlarmEnabled") == "1" ) then
-- We have to load the time manager here if the alarm is enabled because the alarm can go off
-- even if the clock is not shown. WorldFrame_OnUpdate handles alarm checking while the clock
-- is hidden.
TimeManager_LoadUI();
end
...
elseif ( event == "PLAYER_LOGIN" ) then
TimeManager_LoadUI();
If it still somehow didn't load, TimeManager_LoadUI() is called when /stopwatch is used.
Since it should load at PLAYER_LOGIN, I suggest watching ADDON_LOADED like the Stopwatch does:
Lua Code:
function StopwatchFrame_OnEvent(self, event, ...)
if ( event == "ADDON_LOADED" ) then
local name = ...;
if ( name == "Blizzard_TimeManager" ) then
Or just force it with TimeManager_LoadUI() a frame before your code.