Jump to content

Module:Sandbox/A2569875

From Wikipedia, the free encyclopedia

local p = {}
local error = require( 'Module:Error' )
local origArgs

function p.symbol(frame)
	-- For calling from #invoke.
	local pframe = frame:getParent()
	local args = pframe.args
	time1='' if (args[1] and args[1] ~= '') then time1 = string.gsub(args[1] , "%s$", "") else return error.error{ 'can not read time' } end
	type1='' if (args[2] and args[2] ~= '') then type1 = string.gsub(args[2] , "%s$", "") else return error.error{ 'unknow type' } end
	if(type1 == '0' or type1 == '0')then
		if(time1 == '0' or time1 == '1ns' or time1 == '1µs' or time1 == '1ms' or time1 == '1s' or time1 == '10s' or time1 == '1min' or time1 == '10min' or time1 == '1hr' or time1 == '10hr')then
			return '-'
		end
		if(time1 == '1day')then
			return 'V'
		end
		if(time1 == '10day' or time1 == '1mon')then
			return 'I'
		end
		if(time1 == '100day' or time1 == '10mon')then
			return 'B'
		end
		if(time1 == '10y' or time1 == '10a' or time1 == '100y' or time1 == '100a' or time1 == '1ka')then
			return 'G'
		end
		if(time1 == '10ka' or time1 == '100ka' or time1 == '1Ma' or time1 == '10Ma' or time1 == '100Ma')then
			return 'Y'
		end
		if(time1 == '103Ma')then
			return 'O'
		end
		if(time1 == '700Ma' or time1 == '1Ga' or time1 == '10Ga' or time1 == '14Ga' or time1 == '100Ga' or time1 == '1Ta')then
			return 'O'
		end
		if(time1 == 'Stable')then
			return 'R'
		end
	end
	if(type1 == '1' or type1 == '1')then
		if(time1 == '0' or time1 == '1ns' or time1 == '1µs' or time1 == '1ms' or time1 == '1s' or time1 == '10s' or time1 == '1min' or time1 == '10min' or time1 == '1hr' or time1 == '10hr'
			or time1 == '1day' or time1 == '10day' or time1 == '1mon' or time1 == '100day' or time1 == '10mon')then
			return '-'
		end
		if(time1 == '1y' or time1 == '1a')then
			return '0'
		end
		if(time1 == '10y' or time1 == '10a')then
			return '1'
		end
		if(time1 == '100y' or time1 == '100a')then
			return '2'
		end
		if(time1 == '1ka')then
			return '3'
		end
		if(time1 == '10ka')then
			return '4'
		end
		if(time1 == '100ka')then
			return '5'
		end
		if(time1 == '1Ma')then
			return '6'
		end
		if(time1 == '10Ma' or time1 == '100Ma')then
			return '7'
		end
		if(time1 == '103Ma')then
			return '8'
		end
		if(time1 == '700Ma' or time1 == '1Ga' or time1 == '10Ga' or time1 == '14Ga' or time1 == '100Ga' or time1 == '1Ta')then
			return '9'
		end
		if(time1 == 'Stable')then
			return 'R'
		end
	end
	return time_value
end