Title: Module:Effective protection expiry - freem URL Source: https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry Markdown Content: From freem _Documentation for this module may be created at [Module:Effective protection expiry/doc](https://freemwiki.com/index.php?title=Module:Effective\_protection\_expiry/doc&action=edit&redlink=1 "Module:Effective protection expiry/doc (page does not exist)")_ [](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-1)local p = {}[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-2)[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-3)-- Returns the expiry of a restriction of an action on a given title, or unknown if it cannot be known.[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-4)-- If no title is specified, the title of the page being displayed is used.[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-5)function p._main(action, pagename)[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-6)local title[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-7)if type(pagename) == 'table' and pagename.prefixedText then[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-8)title = pagename[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-9)elseif pagename then[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-10)title = mw.title.new(pagename)[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-11)else[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-12)title = mw.title.getCurrentTitle()[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-13)end[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-14)pagename = title.prefixedText[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-15)if action == 'autoreview' then[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-16)local stabilitySettings = mw.ext.FlaggedRevs.getStabilitySettings(title)[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-17)return stabilitySettings and stabilitySettings.expiry or 'unknown'[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-18)elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-19)error( 'First parameter must be one of edit, move, create, upload, autoreview', 2 )[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-20)end[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-21)local rawExpiry = mw.getCurrentFrame():callParserFunction('PROTECTIONEXPIRY', action, pagename)[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-22)if rawExpiry == 'infinity' then[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-23)return 'infinity'[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-24)elseif rawExpiry == '' then[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-25)return 'unknown'[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-26)else[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-27)local year, month, day, hour, minute, second = rawExpiry:match([](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-28)'^(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)$'[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-29))[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-30)if year then[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-31)return string.format([](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-32)'%s-%s-%sT%s:%s:%s',[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-33)year, month, day, hour, minute, second[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-34))[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-35)else[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-36)error('internal error in Module:Effective protection expiry; malformed expiry timestamp')[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-37)end[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-38)end[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-39)end[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-40)[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-41)setmetatable(p, { __index = function(t, k)[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-42)return function(frame)[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-43)return t._main(k, frame.args[1])[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-44)end[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-45)end })[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-46)[](https://freemwiki.com/index.php?oldid=579582&title=Module%3AEffective_protection_expiry#L-47)return p