Module:Wikidata: Difference between revisions

Content deleted Content added
tidy module so that all local functions are available to the global functions
update function getDateValue to make use of the formatting ability already written for the latter functions
Line 546:
end
 
-- This is used to get a date value for date_of_birth (P569), etc. which won't be linked
-- is "time". Dates and times are stored in ISO 8601 format (sort of).
-- be linked -- consolidate by testing if entity.claims[propertyID].mainsnak.datavalue.type
-- At present the local formatDate(date, precision, timezone) function doesn't handle timezone
-- is "time". Dates and times are stored in ISO 8601 format.
-- So I'll just supply "Z" in the call to formatDate below:
p.getDateValue = function(frame)
local propertyID = mw.text.trim(frame.args[1] or "")
Line 559 ⟶ 560:
local out = {}
for k, v in pairs(entity.claims[propertyID]) do
if v.mainsnak.snaktypedatavalue.type == 'valuetime' then
local timestamp = v.mainsnak.datavalue.value.time
iflocal dateprecision = v.mainsnak.datavalue.value.precision == 9 then
out[#out + 1] = parseDateValueformatDate(timestamp, date_formatdateprecision, date_addon"Z")
-- we only have the year, so override any supplied date format with "y"
date_format = "y"
end
out[#out + 1] = parseDateValue(timestamp, date_format, date_addon)
end
end