Module:Events

local f = require('Module:Functions') local p = {} p.data = mw.loadData('Module:Events/data') p.config = { currentEventPictureSizeX = 400, currentEventPictureSizeY = 200, eventTextOverflow = 'overflow: hidden;'.. 'display: -webkit-box;'.. '-webkit-line-clamp: 3;'.. '-webkit-box-orient: vertical;' }

local function checkTime(stop) local a = f.split(stop,"-") stop = os.time{hour = a[4], day = a[3], month = a[2], year = a[1]} return (os.time < stop) end

local function formatTime(t) local a = f.split(t,"-") return os.date('%A, %d. %B %Y at %H:%M UTC', os.time({year=a[1], month=a[2], day=a[3], hour=a[4], minute=0})) end

function p.currentEvent local data = {' '} local active = 0 local style = ' style="padding-right:10px;"' for i, j in pairs(p.data) do		if(checkTime(j.endDate)) then if(active>0) then table.insert(data, '') else table.insert(data, ' ') end table.insert(data,' '..j.endDate..' ') table.insert(data,'') table.insert(data,' Details') table.insert(data, ' ') active = active+1 end end table.insert(data, ' ') if(active == 0) then table.insert(data,'There is no active event right now Add event here') end return table.concat(data,"\n") end

function p.eventList local data = {' '} local past = {} for i, j in pairs(p.data) do		if(checkTime(j.endDate)) then table.insert(data,' ') table.insert(data, '') table.insert(data,' ') table.insert(data,'Start date: '..formatTime(j.startDate)) table.insert(data,' End date: '..formatTime(j.endDate)) table.insert(data,''..j.decription..' ') table.insert(data, ' ') table.insert(data, ' ') else table.insert(past,' ') table.insert(past, '') table.insert(past,' ') table.insert(past,'Start date: '..formatTime(j.startDate)) table.insert(past,' End date: '..formatTime(j.endDate)) table.insert(past,''..j.decription..' ') table.insert(past, ' ') table.insert(past, ' ') end end table.insert(data,'==Past Events==') table.insert(data,table.concat(past,"/n")) table.insert(data,' ') return table.concat(data,"\n") end

return p