Module:FeaturedArticles

local p = {} -- retrieves the database local featured = mw.loadData("Module:FeaturedArticles/data").featured local brandnew = mw.loadData("Module:FeaturedArticles/data").brandnew

function p.item(frame) local data if frame.args[1] == "new" then data = brandnew else data = featured end local timeTable = os.date("*t", os.time) local year = timeTable.year local month = timeTable.month local monthName = os.date("%B", os.time) for k,v in pairs(data) do       if v.year == year and v.month == month then local string = monthName .. ", " .. year .. " - '''" .. v.name .. "'\n\n" .. v.desc .. "''"           return string end end local string if frame.args[1] == "new" then string = monthName .. ", " .. year .. " - N/A\n\nNo brand new content this month" else string = monthName .. ", " .. year .. " - N/A\n\nNo featured article this month" end return string end

function p.allItems(frame) local data if frame.args[1] == "new" then data = brandnew else data = featured end local string = "" local first = 1 local timeTable = os.date("*t", os.time) local year = timeTable.year local month = timeTable.month for k,v in pairs(data) do       if v.year < year or (v.year == year and v.month <= month) then if first == 1 then first = 0 else string = string .. "\n\n" end local monthName = os.date("%B", os.time({year = 2000, month = v.month, day = 1})) string = string .. monthName .. ", " .. v.year .. " - '''" .. v.name .. "'\n\n" .. v.desc .. "''"       end end return string end

return p