Module:Protection banner: Difference between revisions

m 1 revision imported
m 1 revision imported
 
(One intermediate revision by one other user 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