"इस मॉड्यूल हेतु प्रलेख मॉड्यूल:Era/doc पर बनाया जा सकता है"

--[[
  Get the name of an era, based on Wikisource's definition.
  This implements the logic of Template:What era is
--]]
require('strict')

local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.main(frame)
	local args = getArgs(frame, {
		wrappers = {
			'साँचा:What era is',
		}
	})
	return p.era(args[1])
end

function p.era(year)
	-- Nil years need to trigger bailout before we do anything else.
	if year == nil then
		return 'अज्ञात युग'
	end

	--[[
		The template (What era is) treated every year that failed to parse as
		"Ancient", and years given as "BCE" fell into this category. With the
		module logic this no loonger works, so we need to treat BCE years as
		negative instead, so the numeric logic can deal wiith them.
	--]]
	if mw.ustring.match(year, ' BCE$') ~= nil then
		year = mw.ustring.gsub(year, ' BCE$', '') -- Strip the "BCE"
		year = '-' .. year -- And prepend a minus (we tonumber() it later)
	end

	-- Unknown value.
	if tonumber(year) == nil or mw.ustring.lower(year) == 'unknown' or year == '?' then
		return 'अज्ञात युग'
	end

	-- Handle numeric years.
	year = tonumber(year)
	local today = tonumber(os.date('%Y'))
	if year <= 600 then
		return 'प्राचीन'
	elseif year <= 1420 then
		return 'मध्युगीन'
	elseif year <= 1630 then
		return 'पुनर्जागरण'
	elseif year <= 1900 then
		return 'आरंभिक आधुनिक'
	elseif year <= today then
		return 'आधुनिक'
	else
		return 'भविष्य'
	end
end


return p