Module:Sandbox/CanonNi: Difference between revisions

Content deleted Content added
...and of course lua does it the weird way
alright
 
(14 intermediate revisions by the same user not shown)
Line 5:
 
function p.main(frame)
local day
local day = Date(frame.args[1]) or string.format('%s %s %s', current.day, current.month, current.year)
return ": ''As of " .. day .. frame.args[2]
if frame.args[1] then
local success, result = pcall(function() return Date(frame.args[1]):text('dmy') end)
if success then
day = result
else
error('Invalid date format in Template:Update.')
end
else
day = Date(current.year, current.month, current.day):text('dmy') + '[[Category:Pages using updated template with missing date]]'
end
--check for extra args
local extra = ''
if frame.args[3] and mw.title.getCurrentTitle() == 0 then
extra = '[[Category:Pages using updated template with unknown parameters]]'
end
return string.format(": ''As of %s%s%s''" .., day .., frame.args[2] or '', extra)
end