Anonymous user
Module:Protection banner: Difference between revisions
format date output in the Blurb class
Enwikipedia>Mr. Stradivarius (validate expiry and protection dates) |
Enwikipedia>Mr. Stradivarius (format date output in the Blurb class) |
||
Line 183:
url = tostring(url)
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
Line 301 ⟶ 310:
local protectionDate = self._protectionStatusObj:getProtectionDate()
if type(protectionDate) == 'number' then
▲ date = date:gsub('^ ', '') -- The %e option replaces leading zeroes with spaces, but we don't want spaces.
▲ return date
else
return protectionDate
Line 344 ⟶ 351:
-- @TODO: Check to see if the expiry is valid.
local expiry = self._protectionStatusObj:getExpiry()
if expiry == 'indef' then
return
elseif type(expiry) == 'number' then
local formatted = Blurb.formatDate(expiry)
return ''▼
return ' until ' .. formatted
elseif expiry then
-- Expiry is an error string.
end
end
|