Module:MiniEvent

-- Test LUA script to get Mini Event information --

local p = {}

local meData = mw.loadData( 'Module:MiniEvent/data' ) --local date = require('Dev:Date')

-- Local Functions -- local function getArgs(frame) local tArgs

if frame == mw.getCurrentFrame then fParent = frame:getParent tArgs = fParent.args

if (fParent.args[1]) then tArgs = fParent.args else tArgs = frame.args end else tArgs = frame end return tArgs end

-- Date -- local function strDate(mon_day) local months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}

local mon = months[math.floor(mon_day/100)] local day = math.fmod(mon_day, 100) local idd = math.fmod(mon_day, 10) local nth = (idd==1 and day~=11 and "st ") or (idd==2 and day~=12 and "nd ") or (idd==3 and day~=13 and "rd ") or "th " return (day .. nth .. mon) end

-- Single Event -- local function singleEvent(sName, sNumber, outType, altText) local eventName  = "Work In Progress" local eventNumber = "Unknown Event" local eventYear  = nil

local outText  = eventName local dispText = "" local dateText = ""

if meData[sName] and meData[sName][sNumber] then eventName  = meData[sName][sNumber][1] eventNumber = meData[sName][sNumber][2] eventYear  = meData[sName][sNumber][3] eventDate  = meData[sName][sNumber][4] outText = eventName .. " Mini Event" end

if outType:match("^[AD]$") then if outType == "A" then dispText = altText elseif outType == "D" then if altText ~= "" then dispText = altText else dispText = eventName .. " #" .. eventNumber end dateText = " Mini Event on the " .. strDate(eventDate) .. " " .. eventYear end end if outType == "D" then outText = outText .. "#" .. eventName .. " #" .. eventNumber .. "|" .. eventName .. " #" .. eventNumber elseif outType == "A" then outText = outText .. "#" .. eventName .. " #" .. eventNumber .. "|" .. altText else outText = outText .. "#" .. eventName .. " #" .. eventNumber .. "|" .. eventName .. " Mini Event" end outText = "" .. outText .. ""

if dateText and dateText ~="" then outText = outText .. dateText end return outText end

-- function get Limited Time Event function p.getME(frame)

local tArgs = getArgs(frame)

local sName   = tArgs[1] or "" local sNumber = tArgs[2] or "" local outType = tArgs[3] or "" local altText = tArgs[4] or ""

sName = sName:lower:gsub("^%s*(.-)%s*$", "%1") or ''

if not sNumber or sNumber == "" then outText = "" .. eventName .. " Mini Event" end

sNumber = sNumber:upper outType = outType:upper

return singleEvent(sName, sNumber, outType, altText) end return p

-- --