Changes

Jump to navigation Jump to search

Module:Protection banner

282 bytes added, 11:21, 23 June 2014
format date output in the Blurb class
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)
-- The %e option replaces leading zeroes with spaces, but we don't want
-- spaces.
date = date:gsub('^ ', '')
return date
end
local protectionDate = self._protectionStatusObj:getProtectionDate()
if type(protectionDate) == 'number' then
local date = osreturn Blurb.dateformatDate('%e %B %Y', protectionDate) date = date:gsub('^ ', '') -- The %e option replaces leading zeroes with spaces, but we don't want spaces. return date
else
return protectionDate
-- @TODO: Check to see if the expiry is valid.
local expiry = self._protectionStatusObj:getExpiry()
if expiry == 'indef' then return nil elseif type(expiry) == 'number' then local formatted = Blurb.formatDate(expiry) return ' until ' .. formatted elseif expirythen else -- Expiry is an error string. return ''expiry
end
end
Anonymous user

Navigation menu