localp={}localgetArgs=require('Module:Arguments').getArgslocaldiag="";localvalidmonth={["january"]="OK",["february"]="OK",["march"]="OK",["april"]="OK",["may"]="OK",["june"]="OK",["july"]="OK",["august"]="OK",["september"]="OK",["october"]="OK",["november"]="OK",["december"]="OK"}functionisValidMonth(s)-- local mymonth = mw.ustring.gsub(s, "^%s*(.*%S)%s+%d%d%d%d%s*$", "$1")localmymonth=mw.ustring.gsub(s,"%s+%d%d%d%d%s*$","")diag=diag.."\nmonthparse = ["..s.."] / ["..mymonth.."]\n"if(validmonth[string.lower(mymonth)]=="OK")thenreturntrueendreturnfalseendfunctionp.main(frame)localrawcats={}localnvalid=0localargs=getArgs(frame)locallistedargslist="";fori,vinipairs(frame.args)dolistedargslist=listedargslist.."* i=["..i.."] v = ["..v.."]\n"endlocalelectionyear=args['electionyear'];if(electionyear==nil)thenelectionyear=""endlistedargslist=listedargslist.."electionyear = ["..electionyear.."]\n"diag=diag..listedargslistif((electionyear==nil)or(mw.ustring.match(electionyear,"^%s*$")~=nil))thenreturndiag.."[[:Category:CanElecResTopTest with nil value]]"elseif(mw.ustring.match(electionyear,"^%s*%d%d%d%d%s*$")~=nil)thenreturndiag.."[[:Category:CanElecResTopTest with bare year]]"elseif(mw.ustring.match(electionyear,"^.*%s+%d%d%d%d%s*$")~=nil)thenif(isValidMonth(electionyear))thenreturndiag.."[[:Category:CanElecResTopTest with month year]]"elsereturndiag.."[[:Category:CanElecResTopTest with something before year]]"endelsereturndiag.."[[:Category:CanElecResTopTest with unrecognised value]]"endendreturnp