Module:PageDates

From HighSpell Wiki
Revision as of 22:56, 4 June 2025 by Ryan (talk | contribs) (Created page with "local p = {} function p.dates(frame) local title = mw.title.getCurrentTitle() local firstRev = title:getFirstRevision() local lastRev = title:getLatestRevID() if not firstRev then return "Page history not available." end local createdTimestamp = firstRev.timestamp local updatedTimestamp = title:getTimestamp() local lang = mw.language.getContentLanguage() local createdDate = lang:formatDate("j F Y", createdTimestamp) loc...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:PageDates/doc

local p = {}

function p.dates(frame)
    local title = mw.title.getCurrentTitle()
    local firstRev = title:getFirstRevision()
    local lastRev = title:getLatestRevID()

    if not firstRev then
        return "Page history not available."
    end

    local createdTimestamp = firstRev.timestamp
    local updatedTimestamp = title:getTimestamp()

    local lang = mw.language.getContentLanguage()
    local createdDate = lang:formatDate("j F Y", createdTimestamp)
    local updatedDate = lang:formatDate("j F Y", updatedTimestamp)

    if createdDate == updatedDate then
        return string.format("It was added on %s.", createdDate)
    else
        return string.format("It was added on %s and revised on or before %s.", createdDate, updatedDate)
    end
end

return p