User:2d37/Prep/acstats.lua

local p = {} local us = mw.ustring local insert = table.insert local concat = table.concat local Date = require('Module:Date')._Date

local function parse_AC_timeline(page_title) local input = mw.title.new(page_title):getContent local output = { '{| class="wikitable sortable"\n'; '|-\n'; '! Arbitrator !! Years on ArbCom !! First joined ArbCom !! Last left ArbCom\n'; }	local function parse_line(line) local user = us.match(line, '%[%%+)') if not user then return end local start_day, start_month, start_year = line:match '%f[%S]from:%s*(%d%d)/(%d%d)/(%d%d%d%d)%f[%D]' local end_day, end_month, end_year = line:match '%f[%S]till:%s*(%d%d)/(%d%d)/(%d%d%d%d)%f[%D]' return { user = user; start_date = Date(start_year, start_month, start_day); end_date = Date(end_year, end_month, end_day); }	end local function process_line(line) line = parse_line(line) if not line then return end mw.logObject(line) insert(output, '|-\n| ') insert(output, tostring(line.user)) insert(output, ' || || ') insert(output, tostring(line.start_date)) insert(output, ' || ') insert(output, tostring(line.end_date)) end for line in us.gmatch(input, '[^\n]+') do		process_line(line) end insert(output, '|}') return concat(output) end

return parse_AC_timeline('Template:Arbitration committee chart/2004–2009')