<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.tiffa.net/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ATitle_monthname</id>
	<title>Module:Title monthname - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.tiffa.net/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ATitle_monthname"/>
	<link rel="alternate" type="text/html" href="https://wiki.tiffa.net/w/index.php?title=Module:Title_monthname&amp;action=history"/>
	<updated>2026-04-15T22:29:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.tiffa.net/w/index.php?title=Module:Title_monthname&amp;diff=162868&amp;oldid=prev</id>
		<title>Fire: Created page with &quot;-- v1.00      Split the page title into words then test each of them against      the list of months.      Optionally, an alternative page name may be supplied as a parameter.      Return the first word which matches a months name ...      unless the &quot;match=&quot; parameter specifies a diffreent match.      If there is no match, then return an empty string ... unles      the &quot;nomatch&quot; parameter specifies something different   local getArgs = require(&#039;Module:Arguments&#039;).ge...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.tiffa.net/w/index.php?title=Module:Title_monthname&amp;diff=162868&amp;oldid=prev"/>
		<updated>2025-07-15T06:05:42Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;--[[ v1.00      Split the page title into words then test each of them against      the list of months.      Optionally, an alternative page name may be supplied as a parameter.      Return the first word which matches a months name ...      unless the &amp;quot;match=&amp;quot; parameter specifies a diffreent match.      If there is no match, then return an empty string ... unles      the &amp;quot;nomatch&amp;quot; parameter specifies something different ]]  local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).ge...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[ v1.00&lt;br /&gt;
     Split the page title into words then test each of them against&lt;br /&gt;
     the list of months.&lt;br /&gt;
     Optionally, an alternative page name may be supplied as a parameter.&lt;br /&gt;
     Return the first word which matches a months name ...&lt;br /&gt;
     unless the &amp;quot;match=&amp;quot; parameter specifies a diffreent match.&lt;br /&gt;
     If there is no match, then return an empty string ... unles&lt;br /&gt;
     the &amp;quot;nomatch&amp;quot; parameter specifies something different&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- config&lt;br /&gt;
local nomatch = &amp;quot;&amp;quot;&lt;br /&gt;
local matchnum = 1&lt;br /&gt;
&lt;br /&gt;
local monthList = {&lt;br /&gt;
	&amp;#039;January&amp;#039;,&lt;br /&gt;
	&amp;#039;February&amp;#039;,&lt;br /&gt;
	&amp;#039;March&amp;#039;,&lt;br /&gt;
	&amp;#039;April&amp;#039;,&lt;br /&gt;
	&amp;#039;May&amp;#039;,&lt;br /&gt;
	&amp;#039;June&amp;#039;,&lt;br /&gt;
	&amp;#039;July&amp;#039;,&lt;br /&gt;
	&amp;#039;August&amp;#039;,&lt;br /&gt;
	&amp;#039;September&amp;#039;,&lt;br /&gt;
	&amp;#039;October&amp;#039;,&lt;br /&gt;
	&amp;#039;November&amp;#039;,&lt;br /&gt;
	&amp;#039;December&amp;#039;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- splits a string into &amp;quot;words&amp;quot;&lt;br /&gt;
-- a &amp;quot;word&amp;quot; is a set of characters delineated at each end by one &lt;br /&gt;
--    or more whitespace characters or punctaution charaters&lt;br /&gt;
function splitIntoWords(str)&lt;br /&gt;
	result = {}&lt;br /&gt;
	index = 1&lt;br /&gt;
	s = mw.ustring.gsub(str, &amp;quot;^[%s%p]+&amp;quot;, &amp;quot;&amp;quot;) -- strip leading whitespace or punctuation&lt;br /&gt;
	for s2 in mw.ustring.gmatch(s, &amp;quot;[^%s%p]+[%s%p]*&amp;quot;) do&lt;br /&gt;
		s3 = mw.ustring.gsub(s2, &amp;quot;[%s%p]+$&amp;quot;, &amp;quot;&amp;quot;) -- strip trailing separators&lt;br /&gt;
		result[index] = s3&lt;br /&gt;
		index = index + 1&lt;br /&gt;
	end&lt;br /&gt;
return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- returns the first word is the pagename which matches the name of a month&lt;br /&gt;
-- ... or an empty string if there is no match&lt;br /&gt;
function checkPagename(pn)&lt;br /&gt;
	-- split the pagename into sparate words&lt;br /&gt;
	titleWords = splitIntoWords(pn)&lt;br /&gt;
	&lt;br /&gt;
	nMatches = 0&lt;br /&gt;
	myMatches ={}&lt;br /&gt;
	&lt;br /&gt;
	-- check each words in turn, to see if it matches a month&lt;br /&gt;
	for w, thisWord in ipairs(titleWords) do&lt;br /&gt;
		-- check agaist each month&lt;br /&gt;
		-- if there is a match, then return that monthname&lt;br /&gt;
		for i, thisMonth in ipairs(monthList) do&lt;br /&gt;
			if (thisMonth == thisWord) then&lt;br /&gt;
				nMatches = nMatches + 1&lt;br /&gt;
				myMatches[nMatches] = thisMonth&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (nMatches == 0) then&lt;br /&gt;
		-- none of the title words matches a whole month&lt;br /&gt;
		return nomatch&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if ((matchnum &amp;gt;= 1) and (matchnum &amp;lt;= nMatches)) then&lt;br /&gt;
		return myMatches[matchnum]&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (matchnum &amp;lt; 0) then&lt;br /&gt;
		matchnum = matchnum + 1 -- so that -1 is the last match etc&lt;br /&gt;
		if ((matchnum + nMatches) &amp;gt;= 1) then&lt;br /&gt;
			return myMatches[matchnum + nMatches]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- if we get here, we have not found a match at the position specified by &amp;quot;matchnum&amp;quot;&lt;br /&gt;
	return nomatch&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	return p._main(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	if (args[&amp;#039;nomatch&amp;#039;] ~= nil) then&lt;br /&gt;
		nomatch = args[&amp;#039;nomatch&amp;#039;]&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- by default, we return the first match&lt;br /&gt;
	-- but the optional &amp;quot;C&amp;quot; paarmeter sets the &amp;quot;matchnum&amp;quot; variable, which&lt;br /&gt;
	-- * for a positive matchnum &amp;quot;n&amp;quot;, returns the nth match if it exists&lt;br /&gt;
	-- * for a positive matchnum &amp;quot;n&amp;quot;, returns (if it exists) the nth match&lt;br /&gt;
	--   counting backwards from the end.&lt;br /&gt;
	--   So &amp;quot;match=-1&amp;quot; returns the last match&lt;br /&gt;
	--   and &amp;quot;match=-3&amp;quot; returns the 3rd-last match&lt;br /&gt;
	if (args[&amp;#039;match&amp;#039;] ~= nil) then&lt;br /&gt;
		matchnum = tonumber(args[&amp;#039;match&amp;#039;])&lt;br /&gt;
		if ((matchnum == nil) or (matchnum == 0)) then&lt;br /&gt;
			matchnum = 1&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- by default, we use the current page&lt;br /&gt;
	-- but if the &amp;quot;page=&amp;quot; parameters is supplied, we use that&lt;br /&gt;
	-- so we try the parameter first&lt;br /&gt;
	thispagename = nil&lt;br /&gt;
	if ((args[&amp;#039;page&amp;#039;] ~= nil) and (args[&amp;#039;page&amp;#039;] ~= &amp;quot;&amp;quot;)) then&lt;br /&gt;
		-- we have a non-empty &amp;quot;page&amp;quot; parameter, so we use it&lt;br /&gt;
		thispagename = args[&amp;#039;page&amp;#039;]&lt;br /&gt;
	else&lt;br /&gt;
		-- get the page title&lt;br /&gt;
		thispage = mw.title.getCurrentTitle()&lt;br /&gt;
		thispagename = thispage.text;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- now check the pagename to try to find a month ananme&lt;br /&gt;
	result = checkPagename(thispagename)&lt;br /&gt;
	if (result == &amp;quot;&amp;quot;) then&lt;br /&gt;
		return nomatch&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Fire</name></author>
	</entry>
</feed>