Jump to content

Module:Year navigation

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SWinxy (talk | contribs) at 01:51, 19 August 2023 (initial test). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
local getArgs = require("Module:Args").getArgs
local infobox = require("Module:Infobox")

local p = {}

function p._main(args)
	local year = args[1]
	
	if year == 0 then
		return error("Year cannot be 0. There was no [[year 0]].")
	end
	
	local millenium
	
	if year > 2000 then
		millenium = [[3rd millenium]]
	elseif year > 1000 then
		millenium = [[2nd millenium]]
	elseif year > 0 then
		millenium = [[1st millenium]]
	else
		millenium = [[1st millenium BC|1st millenium <small>BC</small>]]
	end
	
	return infobox.infobox({
		label1 = "[[List of decades, centuries, and millennia|Millennium]]:",
		data1 = millenium
	})
end

function p.main(frame)
	local args = getArgs(frame)
	if not args[1] then
		args[1] = frame:getTitle()
	end
	
	return p._main(args)
end

return p