Kontent qismiga oʻtish

Modul:Ancient Egypt era

Vikipediya, ochiq ensiklopediya

Bu modul uchun Modul:Ancient Egypt era/doc nomli hujjat sahifasini yaratishingiz mumkin

local data = mw.loadData( 'Module:Ancient Egypt era/data' )
local lang = mw.language.getContentLanguage()

local p = {}

function p._main( inputYear )
	-- 
	inputYear = tonumber( inputYear )
	if not inputYear or inputYear > tonumber( lang:formatDate( 'Y' ) ) then
		return "''—''"
	end

	-- 
	local dataLength = 0
	for i, t in ipairs( data ) do
		dataLength = i
	end

	for i = dataLength, 1, -1 do
		local t = data[i]
		if inputYear - 1 >= t.dynstart and inputYear - 1 <= t.dynend then
			
			return string.format(
				'[[%s|%s]] [[List of ancient Egyptian dynasties|dynasty]], %d',
				t.dynlink, t.dynasty, inputYear - t.dynstart
			)
		end
	end
end

function p.main( frame )

	local args = require( 'Module:Arguments' ).getArgs( frame, {
		parentOnly = true
	} )
	return p._main( args[ 1 ] )
end

return p