Jump to content

Module:College football conference

From Wikipedia, the free encyclopedia

-- this module implements [[Template:College football conference]]

local p = {}

function p._main(year, school)
	if school then
		local data = require('Module:College football conference/data')
		local alias = require('Module:College football conference/alias')
		year = tonumber(year) or 0
		local t = data[alias[school] or school]
		if not t then
			return "N/A"
		end
		for k,v in pairs(t) do
			k = mw.ustring.gsub(k, '^%s*(%d+)%s*$', '%1-%1')
			if k:match('^%s*%d*[^%d]%d*%s*$') then
				local y1 = mw.ustring.gsub(k, '^%s*(%d*)[^%d](%d*)%s*$', '%1')
				local y2 = mw.ustring.gsub(k, '^%s*(%d*)[^%d](%d*)%s*$', '%2')
				y1 = tonumber(y1) or year
				y2 = tonumber(y2) or year
				if year >= y1 and year <= y2 then
					return v
				end
			end
		end
		return "—"
	end
	return "N/A"
end

function p.main(frame)
	local args = frame:getParent().args
	return p._main(args['year'], args['college'])
end

return p