Module:Convert

local p = {}

function p.normalizeUnit(u) local unit = u	if u == 'tick' then unit = 'game tick' elseif u == 's' or u == 'sec' then unit = 'second' elseif u == 'm' or u == 'min' then unit = 'minute' elseif u == 'day' or u == 'igd' or u == 'in game day' then unit = 'in-game day' end return unit end

function p.convert(value, inputUnit, outputUnit) inputUnit = p.normalizeUnit(inputUnit) outputUnit = p.normalizeUnit(outputUnit) local convertedValue = value local conversions = { ['second -> game tick'] = convertedValue * 20, ['game tick -> second'] = convertedValue / 20, ['second -> redstone tick'] = convertedValue * 10, ['redstone tick -> second'] = convertedValue / 10, ['minute -> second'] = convertedValue * 60, ['second -> minute'] = convertedValue / 60, ['minute -> game tick'] = convertedValue * 20 * 60, ['game tick -> minute'] = convertedValue / 20 / 60, ['minute -> redstone tick'] = convertedValue * 10 * 60, ['redstone tick -> minute'] = convertedValue / 10 / 60, ['in-game day -> minute'] = convertedValue * 20, ['minute -> in-game day'] = convertedValue / 20, ['in-game day -> second'] = convertedValue * 20 * 60, ['second -> in-game day'] = convertedValue / 20 / 60, ['in-game day -> game tick'] = convertedValue * 24000, ['game tick -> in-game day'] = convertedValue / 24000, }	convertedValue = conversions[inputUnit .. ' -> ' .. outputUnit] return convertedValue end

function p.output(f)

local args = f	if f == mw.getCurrentFrame then args = require('Module:ProcessArgs').merge(true) end local value = args[1] local sourceUnit = args[2] local seperator = args['seperator'] or args['sep'] or args['s'] or '('	local endSeperator = ''	if (seperator == '(') then endSeperator = ')' end	local convertedOutput = p.convert(value, sourceUnit, args[3]) .. ' ' .. args[3]	for i,v in ipairs(args) do		if (i > 3 and args[i]) then			convertedOutput = convertedOutput .. '; ' .. p.convert(value, sourceUnit, v) .. ' ' .. v		end	end	return value .. ' ' .. seperator .. convertedOutput .. endSeperator

end

return p