模組:沙盒/魔琴/CNA

维基百科,自由的百科全书
文档图示 模块文档[创建]
local z={}

function t(a)
	if a == nil then
		return ''
	else
		return a
	end
end

function z.main(frame)
	local b=tonumber(frame.args[1])
	local d=tonumber(frame.args[2])
	local p=t(frame.args[3])
	

	
	if b==nil or d==nil then
		return '{{color|red|年份错误}}</span>'
	elseif d<1862 then
		return '请直接使用纯文字表示国籍'
	elseif d<1889 then
		return '{{CHN-1862}}'
	elseif d<1912 then
		return '{{CHN-1889}}'
	elseif b>1912 and d<1928 then
		return '{{CHN-1912}}'
	elseif b>1928 and d<1949 then
		return '{{CHN-1928}}'
	elseif b>1928 and p=='ROC' then
		return '{{ROC}}'
	elseif b>1949 and p=='PRC' then
		return '{{PRC}}'
	else
		
		local s
		s=''
		
		if b<1912 then
			s='{{CHN-1889}}(' .. b .. '年—1911年)<br/>'
			b=1912
		end
		
		if b<1928 then
			s=s..'{{CHN-1912}}(' .. b .. '年—'
			if d<1928 then
				s=s..d..'年)'
				return s
			else
				s=s..'1928年)<br/>'
				b=1928
			end
		end
		
		if p=='ROC' then 
			s = s..'{{ROC}}('..b..'年—'..d..'年)'
		elseif p=='PRC' then
			s = s..'{{CHN-1928}}('..b..'年—1949年)<br/>{{PRC}}(1949年—'..d..'年)'
		else
			if d>1949 then
				s = s..'{{CHN-1928}}('..b..'年—1949年)<br/>错误:1949年以后?'
			else
				s = s..'{{CHN-1928}}('..b..'年—'..d..'年)'
			end
		end
		
		return s
	end	
end

return z