<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.bharatpedia.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ANavseasoncats_with_year_navigation</id>
	<title>Module:Navseasoncats with year navigation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://en.bharatpedia.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ANavseasoncats_with_year_navigation"/>
	<link rel="alternate" type="text/html" href="https://en.bharatpedia.org/w/index.php?title=Module:Navseasoncats_with_year_navigation&amp;action=history"/>
	<updated>2026-09-07T01:04:12Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://en.bharatpedia.org/w/index.php?title=Module:Navseasoncats_with_year_navigation&amp;diff=129300&amp;oldid=prev</id>
		<title>WikiDwarf: Created page with &quot;local p = {} local nsc = require(&#039;Module:Navseasoncats&#039;)  local errorList = { 	[&quot;FIND_VAR&quot;] = &quot;Function find_var can&#039;t recognize the decade for category %s.&quot;, 	[&quot;NO_YEAR&quot;] = &quot;...&quot;</title>
		<link rel="alternate" type="text/html" href="https://en.bharatpedia.org/w/index.php?title=Module:Navseasoncats_with_year_navigation&amp;diff=129300&amp;oldid=prev"/>
		<updated>2021-07-11T16:14:14Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local p = {} local nsc = require(&amp;#039;Module:Navseasoncats&amp;#039;)  local errorList = { 	[&amp;quot;FIND_VAR&amp;quot;] = &amp;quot;Function find_var can&amp;#039;t recognize the decade for category %s.&amp;quot;, 	[&amp;quot;NO_YEAR&amp;quot;] = &amp;quot;...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
local nsc = require(&amp;#039;Module:Navseasoncats&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local errorList = {&lt;br /&gt;
	[&amp;quot;FIND_VAR&amp;quot;] = &amp;quot;Function find_var can&amp;#039;t recognize the decade for category %s.&amp;quot;,&lt;br /&gt;
	[&amp;quot;NO_YEAR&amp;quot;] = &amp;quot;{{Navseasoncats with centuries below decade}} can&amp;#039;t recognize the year for category %s.&amp;quot;,&lt;br /&gt;
	[&amp;quot;NO_DECADE&amp;quot;] = &amp;quot;{{Navseasoncats with centuries below decade}} can&amp;#039;t recognize the decade for category %s.&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local function create_category(firstPart, lastPart, dateValue, dateWord)&lt;br /&gt;
	local category = mw.text.trim(firstPart .. &amp;#039; &amp;#039; .. nsc.addord(dateValue) .. dateWord .. lastPart)&lt;br /&gt;
&lt;br /&gt;
	if (mw.title.new(category, &amp;#039;Category&amp;#039;).exists) then&lt;br /&gt;
		return category&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getCentury(decade)&lt;br /&gt;
	decade = tonumber(decade)&lt;br /&gt;
	local century = math.floor(((decade - 1) / 100) + 1) --from {{CENTURY}}&lt;br /&gt;
	if (string.match(decade, &amp;#039;00$&amp;#039;)) then&lt;br /&gt;
		century = century + 1&lt;br /&gt;
	end --&amp;#039;2000&amp;#039; is technically in the 20th, but the rest of the 2000s is in the 21st&lt;br /&gt;
	&lt;br /&gt;
	return century&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getDecade(year)&lt;br /&gt;
	year = tonumber(year)&lt;br /&gt;
	local decade = year / 10&lt;br /&gt;
	decade = math.floor(decade)&lt;br /&gt;
	return decade .. &amp;quot;0s&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getNestTierDateCategory(dateArgs, dateValue, firstPart, lastPart, decade)&lt;br /&gt;
	local nextTierDateCategory = &amp;quot;&amp;quot;&lt;br /&gt;
	if (dateArgs.dateType == &amp;quot;year&amp;quot;) then&lt;br /&gt;
		local decade = getDecade(dateValue)&lt;br /&gt;
		nextTierDateCategory = create_category(firstPart, lastPart, decade, &amp;quot; &amp;quot;)&lt;br /&gt;
		if (not nextTierDateCategory) then --check for &amp;quot;the YYYY&amp;quot;&lt;br /&gt;
			nextTierDateCategory = create_category(firstPart, lastPart, &amp;quot;the &amp;quot; .. decade, &amp;quot; &amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
	elseif (dateArgs.dateType == &amp;quot;decade&amp;quot;) then&lt;br /&gt;
		local century = getCentury(dateValue)&lt;br /&gt;
		nextTierDateCategory = create_category(firstPart, lastPart, century, &amp;quot; century &amp;quot;)&lt;br /&gt;
		if (not nextTierDateCategory) then --check for hyphenated century&lt;br /&gt;
			nextTierDateCategory = create_category(firstPart, lastPart, century, &amp;quot;-century &amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return nextTierDateCategory&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function isCategoryValid(dateValue, dateType, dateArgs)&lt;br /&gt;
	if ((dateValue) and (dateType == dateArgs.dateType)) then&lt;br /&gt;
		return true&lt;br /&gt;
	else&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getError(pageName, avoidSelf, testcases, errorMessage)&lt;br /&gt;
	local errorOut = &amp;#039;&amp;#039;&lt;br /&gt;
	if (avoidSelf) then&lt;br /&gt;
		local errors = nsc.errorclass(string.format(errorMessage, pageName))&lt;br /&gt;
		errorOut = nsc.failedcat(errors, &amp;#039;P&amp;#039;)&lt;br /&gt;
		if (testcases) then&lt;br /&gt;
			string.gsub(errorOut, &amp;#039;(%[%[)(Category)&amp;#039;, &amp;#039;%1:%2&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return errorOut&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getAvoidSelf(currentTitle, testcases)&lt;br /&gt;
	local avoidSelf = (currentTitle.text ~= &amp;#039;Navseasoncats with year navigation&amp;#039; and&lt;br /&gt;
		currentTitle.text ~= &amp;#039;Navseasoncats with year navigation/doc&amp;#039; and&lt;br /&gt;
		currentTitle.text ~= &amp;#039;Navseasoncats with year navigation/sandbox&amp;#039; and&lt;br /&gt;
		(currentTitle.nsText ~= &amp;#039;Template&amp;#039; or testcases)) --avoid nested transclusion errors&lt;br /&gt;
	return avoidSelf&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function main(frame, dateArgs)&lt;br /&gt;
	local currentTitle = mw.title.getCurrentTitle()&lt;br /&gt;
	local testcases = (currentTitle.subpageText == &amp;#039;testcases&amp;#039;)&lt;br /&gt;
	local avoidSelf = getAvoidSelf(currentTitle, testcases)&lt;br /&gt;
&lt;br /&gt;
	local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	&lt;br /&gt;
	local testcase = args[1]&lt;br /&gt;
&lt;br /&gt;
	if ((testcase == nil) and (avoidself == false)) then&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local pageName = testcase or currentTitle.baseText&lt;br /&gt;
	&lt;br /&gt;
	local findVar = nsc.find_var(pageName) --picks up decades/seasons/etc.&lt;br /&gt;
	if (findVar[1] == &amp;#039;error&amp;#039;) then&lt;br /&gt;
		return getError(pageName, avoidSelf, testcases, errorList[&amp;quot;FIND_VAR&amp;quot;])&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local dateValue = tonumber(string.match(findVar[2], dateArgs.pattern))&lt;br /&gt;
	if (not isCategoryValid(dateValue, findVar[1], dateArgs)) then&lt;br /&gt;
		return getError(pageName, avoidSelf, testcases, dateArgs.errorMessage)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local nav1 = &amp;#039;&amp;#039;&lt;br /&gt;
	if (testcase) then&lt;br /&gt;
		nav1 = frame:expandTemplate{title = &amp;#039;Navseasoncats&amp;#039;, args = {testcase = testcase}} --not sure how else to pass frame &amp;amp; args together&lt;br /&gt;
	else&lt;br /&gt;
		nav1 = nsc.navseasoncats(frame)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local firstPart, lastPart = string.match(pageName, &amp;#039;^(.*)&amp;#039; .. findVar[2] .. &amp;#039;(.*)$&amp;#039;)&lt;br /&gt;
	firstPart = mw.text.trim(firstPart or &amp;#039;&amp;#039;)&lt;br /&gt;
	lastPart  = mw.text.trim(lastPart or &amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
	local nextTierDateCategory = getNestTierDateCategory(dateArgs, dateValue, firstPart, lastPart, decade)&lt;br /&gt;
&lt;br /&gt;
	if (nextTierDateCategory) then&lt;br /&gt;
		local nav2 = frame:expandTemplate{title = &amp;#039;Navseasoncats&amp;#039;, args = {[dateArgs.argName] = nextTierDateCategory}} --not sure how else to pass frame &amp;amp; args together&lt;br /&gt;
		return &amp;#039;&amp;lt;div style=&amp;quot;display:block !important; max-width: calc(100% - 25em);&amp;quot;&amp;gt;&amp;#039; ..&amp;quot;\n&amp;quot; .. nav1 .. nav2 ..&amp;quot;\n&amp;quot; .. &amp;#039;&amp;lt;/div&amp;gt;&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		return nav1&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.centuriesBelowDecade(frame)&lt;br /&gt;
	local dateArgs = {dateType = &amp;quot;decade&amp;quot;, pattern = &amp;#039;^(%d+)s&amp;#039;, argName = &amp;quot;century-below-decade&amp;quot;, errorMessage = errorList[&amp;quot;NO_DECADE&amp;quot;]}&lt;br /&gt;
	return main(frame, dateArgs)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.decadesBelowYear(frame)&lt;br /&gt;
	local dateArgs = {dateType = &amp;quot;year&amp;quot;, pattern = &amp;#039;^(%d+)&amp;#039;, argName = &amp;quot;decade-below-year&amp;quot;, errorMessage = errorList[&amp;quot;NO_YEAR&amp;quot;]}&lt;br /&gt;
	return main(frame, dateArgs)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>WikiDwarf</name></author>
	</entry>
</feed>