Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/BrownHairedGirl/CanElecResTopTest
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local getArgs = require('Module:Arguments').getArgs local diag =""; local validmonth = { ["january"] = "OK", ["february"] = "OK", ["march"] = "OK", ["april"] = "OK", ["may"] = "OK", ["june"] = "OK", ["july"] = "OK", ["august"] = "OK", ["september"] = "OK", ["october"] = "OK", ["november"] = "OK", ["december"] = "OK" } function isValidMonth(s) -- local mymonth = mw.ustring.gsub(s, "^%s*(.*%S)%s+%d%d%d%d%s*$", "$1") local mymonth = mw.ustring.gsub(s, "%s+%d%d%d%d%s*$", "") diag = diag .. "\nmonthparse = [" .. s .. "] / [" .. mymonth .. "]\n" if (validmonth[string.lower(mymonth)] == "OK") then return true end return false end function p.main(frame) local rawcats = {} local nvalid = 0 local args = getArgs(frame) local listedargslist = ""; for i, v in ipairs(frame.args) do listedargslist = listedargslist .. "* i=[" .. i .. "] v = [" .. v .."]\n" end local electionyear =args['electionyear']; if (electionyear == nil) then electionyear = "" end listedargslist = listedargslist .. "electionyear = [" .. electionyear .. "]\n" diag = diag .. listedargslist if ((electionyear == nil) or (mw.ustring.match(electionyear, "^%s*$") ~= nil)) then return diag .. "[[:Category:CanElecResTopTest with nil value]]" elseif (mw.ustring.match(electionyear, "^%s*%d%d%d%d%s*$") ~= nil) then return diag .. "[[:Category:CanElecResTopTest with bare year]]" elseif (mw.ustring.match(electionyear, "^.*%s+%d%d%d%d%s*$") ~= nil) then if (isValidMonth(electionyear)) then return diag .. "[[:Category:CanElecResTopTest with month year]]" else return diag .. "[[:Category:CanElecResTopTest with something before year]]" end else return diag .. "[[:Category:CanElecResTopTest with unrecognised value]]" end end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/BrownHairedGirl/CanElecResTopTest/doc
(
edit
)