Module:UpdateExcerpt: Difference between revisions

m Protected "Module:UpdateExcerpt" ([Edit=Allow moderators and administrators] (indefinite) [Move=Allow moderators and administrators] (indefinite))
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 38: Line 38:


     return html
     return html
end
function p.getDateLink(frame)
    local parentArgs = frame:getParent().args or {}
    local args = frame.args or {}
    local month = parentArgs.month or args.month or parentArgs[1] or args[1] or ""
    local day  = parentArgs.day or args.day or parentArgs[2] or args[2] or ""
    local year  = parentArgs.year or args.year or parentArgs[3] or args[3] or ""
    month = mw.text.trim(month)
    day  = mw.text.trim(day)
    year  = mw.text.trim(year)
    if month == "" or day == "" or year == "" then
        local latestUpdate = require("Module:LatestUpdate")
        if month == "" then month = latestUpdate.month() end
        if day == ""  then day  = latestUpdate.day() end
        if year == ""  then year  = latestUpdate.year() end
    end
    return "[[Update:" .. month .. " " .. day .. ", " .. year .. "| ".. month .. " " .. day .. ", " .. year .. "]]"
end
end