Module:PageDates
Documentation for this module may be created at Module:PageDates/doc
local p = {}
-- Properly handle ordinal suffixes
local function ordinal(n)
local v = n % 100
if v >= 11 and v <= 13 then
return n .. "th"
end
local lastDigit = n % 10
if lastDigit == 1 then return n .. "st"
elseif lastDigit == 2 then return n .. "nd"
elseif lastDigit == 3 then return n .. "rd"
else return n .. "th"
end
end
function p.dates(frame)
local lang = mw.language.getContentLanguage()
local timestamp = frame:preprocess("{{REVISIONTIMESTAMP}}")
-- Extract date parts
local day = tonumber(lang:formatDate("j", timestamp))
local month = lang:formatDate("F", timestamp)
local year = lang:formatDate("Y", timestamp)
local formatted = string.format("%s %s, %s", month, ordinal(day), year)
return formatted
end
return p