Modul:Effective protection expiry

Documentation icon Moduldokumentation
local p = {}-- Returns the expiry of a restriction of an action on a given title, or unknown if it cannot be known.-- If no title is specified, the title of the page being displayed is used.function p._main(action, pagename)local titleif type(pagename) == 'table' and pagename.prefixedText thentitle = pagenameelseif pagename thentitle = mw.title.new(pagename)elsetitle = mw.title.getCurrentTitle()endpagename = title.prefixedTextif action == 'autoreview' thenlocal stabilitySettings = mw.ext.FlaggedRevs.getStabilitySettings(title)return stabilitySettings and stabilitySettings.expiry or 'unknown'elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' thenerror( 'First parameter must be one of edit, move, create, upload, autoreview', 2 )endlocal rawExpiry = mw.getCurrentFrame():callParserFunction('PROTECTIONEXPIRY', action, pagename)if rawExpiry == 'infinity' thenreturn 'infinity'elseif rawExpiry == '' thenreturn 'unknown'elselocal year, month, day, hour, minute, second = rawExpiry:match('^(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)$')if year thenreturn string.format('%s-%s-%sT%s:%s:%s',year, month, day, hour, minute, second)elseerror('internal error in Module:Effective protection expiry; malformed expiry timestamp')endendendsetmetatable(p, { __index = function(t, k)return function(frame)return t._main(k, frame.args[1])endend })return p