Module:Archive header
Documentation for this module may be created at Module:Archive header/doc
local p = {}
local function isGoodYear(candidate)
return (candidate and candidate >= 2002 and candidate <= tonumber(os.date('%Y')))
end
function p._getArchiveType(subpageName)
if isGoodYear(tonumber(subpageName)) then
return 'year'
end
local year, month = string.match(subpageName, '(%d%d%d%d)%-(%d%d)')
if isGoodYear(tonumber(year)) and tonumber(month) >= 1 and tonumber(month) <= 12 then
return 'month'
end
local year, week = string.match(subpageName, '(%d%d%d%d)%-w(%d%d)')
if isGoodYear(tonumber(year)) and tonumber(week) >= 1 and tonumber(week) <= 53 then
return 'week'
end
return nil
end
function p.getArchiveType(frame)
return p._getArchiveType(mw.title.getCurrentTitle().subpageText)
end
return p