Mooduul:Lifespan
Olgoldâshäämi
Taan mooduul ravvuu puáhtá rähtiđ siijđon Mooduul:Lifespan/raavâ
local p = {}
local mw = require("mw")
function p.y(frame)
local entity = mw.wikibase.getEntityObject()
-- If the page is not connected to Wikidata
if not entity then
return ""
end
-- Check if the entity has a birth date (P569)
if entity.claims and entity.claims["P569"] then
local dob = entity.claims["P569"][1].mainsnak.datavalue.value.time
-- Remove leading "+" from "+1879-03-14T00:00:00Z"
dob = string.sub(dob, 2, 11) -- Keep only YYYY-MM-DD
-- Format date using wiki's content language
return mw.language.getContentLanguage():formatDate("j. F Y", dob)
end
-- If no birth date is found
return "Ukjent fødselsdato[[Kategori:Sider uten fødselsår på Wikidata]]"
end
return p