C_Calendar.GetNumDayEvents not working

Hello,
I was looking for a way to remind me when the Darkmoon Fair is active.
I looked into the C_Calendar namespace…

local numDayEvents = C_Calendar.GetNumDayEvents(0, 9)
print(numDayEvents) – returns 0

It works sometimes, but not always. (Hard coded date, calculated date, /script statement, and all addons disabled or enabled, I get the same results, either returns the correct value, or returns 0.

What am I doing wrong ?

The calendar UI is Load On Demand and the CalendarFrame has to have been opened at least once before that will work

 if not IsAddOnLoaded("Blizzard_Calendar") then
	LoadAddOn("Blizzard_Calendar")
	Calendar_Toggle()
	CalendarFrame:Hide()
 end
 print(C_Calendar.GetNumDayEvents(0, 9))

That assumes the CalendarFrame has already been displayed when the addon was loaded originally.

1 Like

Thank you so much. I was wondering why it worked “sometimes”, never even thought because I opened the calendar.

Thank you.