Kontent qismiga oʻtish

Modul:Ancient Olympiads

Vikipediya, ochiq ensiklopediya

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

local data = mw.loadData( 'Module:Ancient Olympiads/data' )
local lang = mw.language.getContentLanguage()
local TableTools = require('Module:TableTools')

local p = {}

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

	-- 
	for i = dataLength, 1, -1 do
		local t = data[i]
		if inputYear - 1 == t.year then
			--  
			return string.format(
				'%s [[Olimpiada]] ([[%s|victor]][[Winner of the Stadion race|)¹]]',
				t.numberOl, t.winner
			)
		end
        if inputYear > t.year then
			--  
			return string.format(
				'[[%s|%s]] [[Olimpiada]], year %d',
				t.yearBC, t.numberOl, inputYear - t.year 
			)
		end
	end


	return string.format(
		'%d before [[Mil. avv. 776|1]]-[[Olimpiada]]',
		inputYear * -1 - 775
	)
end

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

return p