diff --git a/contrib/plugins/calendar/main.lua b/contrib/plugins/calendar/main.lua index ba338b4..bf16007 100644 --- a/contrib/plugins/calendar/main.lua +++ b/contrib/plugins/calendar/main.lua @@ -144,12 +144,24 @@ end -- Get events within a date range (inclusive) function M.get_events(params, end_date) + -- Debug: log what we received + print("get_events: params type=" .. type(params) .. ", end_date type=" .. type(end_date)) + if type(params) == "table" then + for k, v in pairs(params) do + print(" params[" .. tostring(k) .. "] type=" .. type(v)) + end + end -- Backward compat: support positional (start, end) and table {start=, end=} if type(params) == "string" then - return M.get_events{ start_date = params, ["end"] = end_date or params } + print("get_events: backward compat path, end_date=" .. tostring(end_date)) + local e = end_date + if type(e) ~= "string" then e = nil end + return M.get_events{ start_date = params, ["end"] = e or params } end local start_date = params.start_date or params.start + if type(start_date) ~= "string" then print("WARN get_events start_date not string: " .. type(start_date)); start_date = tostring(start_date) end local end_date = params["end"] or params.end_date or params.end_date + if type(end_date) ~= "string" then print("WARN get_events end_date not string: " .. type(end_date)); end_date = start_date end if not start_date then error("start_date required") end if not end_date then end_date = start_date end return verstak.db.query(