Module:Wikidata: Difference between revisions

Content deleted Content added
see if we can quick-fix case when date is just a year and precision is year
`time' is now (?) in ISO format, somebody can properly integrate this with the rest of the code later
Line 226:
if entity.claims[propertyID] ~= nil then
local out = {}
local dt = {}
for k, v in pairs(entity.claims[propertyID]) do
for k2, v2 in pairs(v.qualifiers[qualifierID]) do
if v2.snaktype == 'value' then
local d = v2.datavalue.value.time
if #d > 26 then
dt.year = string.sub(d, 9, 12)
dt.month = string.sub(d, 14, 15)
dt.day = string.sub(d, 17, 18)
else
dt.year = string.sub(d, 9, 10)
dt.month = string.sub(d, 12, 13)
dt.day = string.sub(d, 15, 16)
end
if date_format == "mdy" then
out[#out + 1] = osmw.datelanguage.new(wiki.langcode):formatDate("%BF %ej, %Y", os.time(dt)d)
elseif date_format == "my" then
out[#out + 1] = osmw.datelanguage.new(wiki.langcode):formatDate("%BF %Y", os.time(dt)d)
elseif date_format == "y" then
out[#out + 1] = osmw.datelanguage.new(wiki.langcode):formatDate("%Y", os.time(dt)d)
else
out[#out + 1] = osmw.datelanguage.new(wiki.langcode):formatDate("%ej %BF %Y", os.time(dt)d)
end
end