Module:Year category type
Jump to navigation
Jump to search
| Page extended-confirmed-protected | This module is currently under extended confirmed protection. Extended confirmed protection prevents edits from all unregistered editors and registered users with fewer than 30 days tenure and 500 edits. The policy on community use specifies that extended confirmed protection can be applied to combat disruption, if semi-protection has proven to be ineffective. Extended confirmed protection may also be applied to enforce arbitration sanctions. Please discuss any changes on the talk page; you may submit an edit request to ask for uncontroversial changes supported by consensus. |
Used in Template:Year category header to detect the year type in the category name.
Usage
{{#invoke:Year category type|main}}
local p = {}
local units = {
year = "^%d*$",
year_bc = "^%d* BC$",
year_ad = "^AD %d*$",
decade = "^%d*0s$",
decade_bc = "^%d*0s BC$",
century = "^%d*[snrt][tdh].century$",
century_bc = "^%d*[snrt][tdh].century BC$",
millennium = "^%d*[snrt][tdh].millennium$",
millennium_bc = "^%d*[snrt][tdh].millennium BC$",
}
function p.main(frame)
local title = mw.title.getCurrentTitle().text
for unit, pattern in pairs(units) do
if string.match(title, pattern) then
return unit
end
end
return -1
end
return p