אונטערשייד צווישן ווערסיעס פון "יחידה:עיר"

422 בייטן אראפגענומען ,  פֿאַר 2 יאָר
אפדעיט
(אימפארטירט, פאדערט צופאסונג)
 
(אפדעיט)
שורה 489: שורה 489:
end
end


function returnLatestData(property)
function returnLatestData(frame, property)
local dateModule = require('Module:תאריך')
local dateModule = require('Module:תאריך')
local propertyLink = require('Module:PropertyLink')
local propertyLink = require('Module:PropertyLink')
local parenthesis = require('Module:סוגריים')
local parenthesis = require('Module:סוגריים')


local timeProperty = { 'P582', 'P580', 'P585' }
local timeProperty = { 'P580', 'P582', 'P585' }
local options = {
local options = {
['entity-gender-aware'] =  true,
['qualifiers'] = timeProperty,
['qualifiers'] = timeProperty,
['allowMulti'] = true,
['allowMulti'] = true,
שורה 502: שורה 501:
}
}
local entityId = mw.wikibase.getEntityIdForCurrentPage()
local entityId = frame:getParent().args['qid'] or mw.wikibase.getEntityIdForCurrentPage()
local res = propertyLink.getPropertyByOptions(property, entityId, options)
local res = propertyLink.getPropertyByOptions(property, entityId, options)
return parenthesis.remove_parents_internal(res), parenthesis.only_parents_contents_internal(res)
local propertyList = splitString(res, ';')
if #propertyList == 0 then return end
local dateList = {}
for i, listPro in ipairs(propertyList) do
local temp = pcall(parenthesis.only_parents_contents_internal, listPro)
local temp2 = splitString(temp, ',')
dateList[i] = findTheLatestDate(temp2)
end
local latestIsoDate, indexOfLatestIsoDate = findTheLatestDate(dateList)
-- If needed, you can convert the latest ISO 8601 date back to a readable format
return propertyList[indexOfLatestIsoDate], dateList[indexOfLatestIsoDate]
end
end


function returnLatestMayor(frame)
function returnLatestMayor(frame)
local mayor, latestMayorDate = returnLatestData('P6')
local mayor, latestMayorDate = returnLatestData(frame, 'P6')
return mayor
return mayor
end
end


function returnLatestPopulation(frame)
function returnLatestPopulation(frame)
local population, latestPopulationDate = returnLatestData('P1082')
local population, latestPopulationDate = returnLatestData(frame, 'P1082')
return population
return population
end
end


function returnLatestPopulationDate(frame)
function returnLatestPopulationDate(frame)
local population, latestPopulationDate = returnLatestData('P1082')
local population, latestPopulationDate = returnLatestData(frame, 'P1082')
return latestPopulationDate
return latestPopulationDate
end
end