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

1,261 בייטן צוגעלייגט ,  פֿאַר 2 יאָר
אפדעיט
(אפדעיט)
(אפדעיט)
 
(איין צווישנדיגע ווערסיע פונעם זעלבן באַניצער נישט געוויזן)
שורה 467: שורה 467:
end
end


local function findTheLatestDate(dateList)
local function removeSpanTagsAndKeepText(html)
local iso8601DateList = {}
    local pattern = '<span[^>]*>(.-)</span>'
local latestIsoDate = 0
    local cleanedHtml = html
local indexOfLatestIsoDate = 0
   
    repeat
        local newHtml, count = string.gsub(cleanedHtml, pattern, "%1")
        if count > 0 then
            cleanedHtml = newHtml
        else
            break  -- Exit the loop when no more span tags are found
        end
    until false
   
    return cleanedHtml
end


-- Convert the dates to ISO 8601 format
local function isNumber(str)
for i, isoDate in ipairs(dateList) do
if str == nil or str == "" then return false end
local successOfIso8601DateList
    -- Remove thousands separators (commas) and replace any commas with periods
    successOfIso8601DateList, iso8601DateList[i] = pcall(dateModule.parseStrDate, isoDate, 'TS')
    local r = string.gsub(str, ",", "")
    if (i == 1) then
    r = string.gsub(r, "%.", ".")
    latestIsoDate = iso8601DateList[1]
 
    indexOfLatestIsoDate = 1
    return tonumber(r)
    else
end
    if (latestIsoDate > iso8601DateList[i]) then
 
    latestIsoDate = iso8601DateList[i]
local function extractFirstNumber(inputString)
    indexOfLatestIsoDate = i
if inputString == nil or inputString == "" then return inputString end
    end
    local number = inputString:match("[%d,.]+")
    end
    if number then
end
    return tonumber(number)
return latestIsoDate, indexOfLatestIsoDate
    else
        return inputString  -- No number found, return the original text
    end
end
end


שורה 494: שורה 507:
local parenthesis = require('Module:סוגריים')
local parenthesis = require('Module:סוגריים')


local timeProperty = { 'P580', 'P582', 'P585' }
local timeProperty = { 'P585', 'P580', 'P582' }
local options = {
local options = {
['qualifiers'] = timeProperty,
['qualifiers'] = timeProperty,
['allowMulti'] = true,
['allowMulti'] = true,
['seperator'] = ';'
['seperator'] = ';',
['sort'] = timeProperty
}
}
local entityId = frame:getParent().args['qid'] or 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)
if res == nil or res == "" then
return nil
end
local resArray = splitString(res, ";")
local latestData = resArray[#resArray]
latestData = removeSpanTagsAndKeepText(latestData)
local lastData = parenthesis.remove_parents_internal(latestData)
local lastDate = parenthesis.only_parents_contents_internal(latestData)
local resData = lastData
local resDate = lastDate
if isNumber(extractFirstNumber(lastData)) then
for i = #resArray, 1, -1 do
local ins = resArray[i]
ins = removeSpanTagsAndKeepText(ins)
local insData = parenthesis.remove_parents_internal(ins)
local insDate = parenthesis.only_parents_contents_internal(ins)
    if lastDate ~= insDate then
        break
    end
    if extractFirstNumber(resData) < extractFirstNumber(insData) then
    resData = insData
    end
end
end
return resData, resDate
end
 
function returnLatestArea(frame)
local area, latestAreaDate = returnLatestData(frame, 'P2046')
return area
end
end


שורה 524: שורה 566:
['חלוקה מנהלית']=adminDistTranslateWrapper,
['חלוקה מנהלית']=adminDistTranslateWrapper,
['צבע רקע לפי חלוקה מנהלית']=adminDistTranslateColorWrapper,
['צבע רקע לפי חלוקה מנהלית']=adminDistTranslateColorWrapper,
['שטח']=returnLatestArea,
['ראש העיר']=returnLatestMayor,
['ראש העיר']=returnLatestMayor,
['אוכלוסייה']=returnLatestPopulation,
['אוכלוסייה']=returnLatestPopulation,
['תאריך אוכלוסייה']=returnLatestPopulationDate
['תאריך אוכלוסייה']=returnLatestPopulationDate
}
}