Module:Protection banner: Difference between revisions

enwp>SilverLocust
fix for mobile and search issue, see talk page
m 1 revision imported: Importing template Sfrac
 
(2 intermediate revisions by 2 users not shown)
Line 323: Line 323:


function Protection:isIncorrect()
function Protection:isIncorrect()
local expiry = self.expiry
if not self:shouldHaveProtectionCategory() then
return not self:shouldHaveProtectionCategory()
return true
or type(expiry) == 'number' and expiry < os.time()
end
if type(self.expiry) ~= 'number' then
return false
end
local expiry = os.date('*t', self.expiry)
-- Avoid checking today.day or os.time(), unless close. https://phabricator.wikimedia.org/T416616
local today = os.date('*t')
return (expiry.year < today.year)
or (expiry.year == today.year and expiry.month < today.month)
or (expiry.year == today.year and expiry.month == today.month and expiry.day < today.day)
or (expiry.year == today.year and expiry.month == today.month and expiry.day == today.day and self.expiry < os.time())
end
end