-- Module to return most recent ranking (P1352) from FIFA (Q180825)-- making use of point in time (P585)--
local p =
local i18n =
p.getRanking = function(frame) -- allow us to see all values if debugging - set dbg=true as parameter dbug = frame.args.dbg or false -- see if a qid was supplied for arbitrary access; make empty string into nil local qid = mw.text.trim(frame.args.qid or "") if qid and (#qid
"Q180825" then rank[#rank + 1] = v.mainsnak.datavalue.value.amount timestamp[#rank] = v.qualifiers["P585"][1].datavalue.value.time end end end if rank then local ts = "" local imax = 0 for i, v in ipairs(timestamp) do if v > ts then ts = v imax = i end end local lastdate = tonumber(ts:sub(10, 11)) .. " " .. i18n.months[tonumber(ts:sub(7, 8))] .. " " .. tonumber(ts:sub(2, 5)) local lastrank = tonumber(rank[imax]) if dbug then return table.concat(rank, ", ") .. "
" .. table.concat(timestamp, ", ") .. "
Latest = " .. lastdate .. " rank is " .. lastrank else return lastrank .. " (" .. lastdate .. ")" end else return i18n.errors["ranks-not-found"] endend
return p