Module:Protection banner: Difference between revisions
Content added Content deleted
Enwikipedia>Mr. Stradivarius (validate expiry and protection dates) |
Enwikipedia>Mr. Stradivarius (format date output in the Blurb class) |
||
Line 183: | Line 183: | ||
url = tostring(url) |
url = tostring(url) |
||
return string.format('[%s %s]', url, display) |
return string.format('[%s %s]', url, display) |
||
end |
|||
function Blurb.formatDate(num) |
|||
-- Formats a Unix timestamp into dd M, YYYY format. |
|||
local date = os.date('%e %B %Y', num) |
|||
⚫ | |||
-- spaces. |
|||
date = date:gsub('^ ', '') |
|||
⚫ | |||
end |
end |
||
Line 301: | Line 310: | ||
local protectionDate = self._protectionStatusObj:getProtectionDate() |
local protectionDate = self._protectionStatusObj:getProtectionDate() |
||
if type(protectionDate) == 'number' then |
if type(protectionDate) == 'number' then |
||
return Blurb.formatDate(protectionDate) |
|||
⚫ | |||
⚫ | |||
else |
else |
||
return protectionDate |
return protectionDate |
||
Line 344: | Line 351: | ||
-- @TODO: Check to see if the expiry is valid. |
-- @TODO: Check to see if the expiry is valid. |
||
local expiry = self._protectionStatusObj:getExpiry() |
local expiry = self._protectionStatusObj:getExpiry() |
||
if expiry then |
if expiry == 'indef' then |
||
return |
return nil |
||
elseif type(expiry) == 'number' then |
|||
else |
|||
local formatted = Blurb.formatDate(expiry) |
|||
⚫ | |||
return ' until ' .. formatted |
|||
elseif expiry then |
|||
-- Expiry is an error string. |
|||
⚫ | |||
end |
end |
||
end |
end |