יחידה:LocationAndCountry: הבדלים בין גרסאות בדף

מאין תקציר עריכה
מאין תקציר עריכה
שורה 7: שורה 7:
* offical/short name
* offical/short name
]]
]]


-- will display a wikidata property representing a location, followed by a comma and the name of the country, both with wikilinks
-- will display a wikidata property representing a location, followed by a comma and the name of the country, both with wikilinks
שורה 72: שורה 71:
d2 = HeDateUtils.newFromWikidataValue(q2['P580'][1].datavalue.value)
d2 = HeDateUtils.newFromWikidataValue(q2['P580'][1].datavalue.value)
end
end
if d1 and d2 then return not HeDateUtils.le(d1, d2)
if d1 and d2 then return HeDateUtils.le(d1, d2, true)
elseif d1 then return true
elseif d1 then return true
elseif d2 then return false end
elseif d2 then return false end
שורה 86: שורה 86:


local function findSortedClaimsForProperty(entity, propertyId)
local function findSortedClaimsForProperty(entity, propertyId)
if propertyId == nil then return nil end
if entity == nil then entity = mw.wikibase.getEntityIdForCurrentPage() end
if entity == nil then entity = mw.wikibase.getEntityObject() end
local rawClaims = mw.wikibase.getAllStatements(entity, propertyId)
if type(entity) == 'string' then entity = mw.wikibase.getEntityObject(entity) end
if entity == nil or entity.claims == nil then return nil end
local rawClaims = entity.claims[propertyId]
if rawClaims == nil then return {} end
if rawClaims == nil then return {} end
שורה 110: שורה 106:
if eachPropClaim.qualifiers then
if eachPropClaim.qualifiers then
if eachPropClaim.qualifiers['P580'] and eachPropClaim.qualifiers['P580'][1] and isValueSnak(eachPropClaim.qualifiers['P580'][1]) then
if eachPropClaim.qualifiers['P580'] and eachPropClaim.qualifiers['P580'][1] and isValueSnak(eachPropClaim.qualifiers['P580'][1]) then
after = HeDateUtils.julianToGregorian(HeDateUtils.newFromWikidataValue(eachPropClaim.qualifiers['P580'][1].datavalue.value))
before = HeDateUtils.julianToGregorian(HeDateUtils.newFromWikidataValue(eachPropClaim.qualifiers['P580'][1].datavalue.value))
--after = GregorianDate.convertToGregorianIfInInterval(DateUtils.extractDateFromWikidataSnak(eachPropClaim.qualifiers['P580'][1]))
--after = GregorianDate.convertToGregorianIfInInterval(DateUtils.extractDateFromWikidataSnak(eachPropClaim.qualifiers['P580'][1]))
end
end
if eachPropClaim.qualifiers['P582'] and eachPropClaim.qualifiers['P582'][1] and isValueSnak(eachPropClaim.qualifiers['P582'][1]) then
if eachPropClaim.qualifiers['P582'] and eachPropClaim.qualifiers['P582'][1] and isValueSnak(eachPropClaim.qualifiers['P582'][1]) then
before = HeDateUtils.julianToGregorian(HeDateUtils.newFromWikidataValue(eachPropClaim.qualifiers['P582'][1].datavalue.value))
after = HeDateUtils.julianToGregorian(HeDateUtils.newFromWikidataValue(eachPropClaim.qualifiers['P582'][1].datavalue.value))
--before = GregorianDate.convertToGregorianIfInInterval(DateUtils.extractDateFromWikidataSnak(eachPropClaim.qualifiers['P582'][1]))
--before = GregorianDate.convertToGregorianIfInInterval(DateUtils.extractDateFromWikidataSnak(eachPropClaim.qualifiers['P582'][1]))
end
end
שורה 121: שורה 117:
if before and HeDateUtils.le(timestamp, before) then --the claim list is sorted by before
if before and HeDateUtils.le(timestamp, before) then --the claim list is sorted by before
break
break
elseif after == nil and before and HeDateUtils.le(timestamp, before) then
elseif after == nil and before and not HeDateUtils.le(timestamp, before) then
return eachPropClaim
return eachPropClaim
elseif after and before and HeDateUtils.le(timestamp, before) and not HeDateUtils.le(timestamp, after)  then  
elseif after and before and not HeDateUtils.le(timestamp, before) and HeDateUtils.le(timestamp, after)  then  
return eachPropClaim
return eachPropClaim
elseif after and before == nil and not HeDateUtils.le(timestamp, after) then
elseif after and before == nil and HeDateUtils.le(timestamp, after) then
return eachPropClaim
return eachPropClaim
end
end
שורה 131: שורה 127:
if not bestClaim or mw.wikibase.entity.claimRanks['RANK_' .. mw.ustring.upper(bestClaim.rank)] < mw.wikibase.entity.claimRanks['RANK_' .. mw.ustring.upper(eachPropClaim.rank)]  
if not bestClaim or mw.wikibase.entity.claimRanks['RANK_' .. mw.ustring.upper(bestClaim.rank)] < mw.wikibase.entity.claimRanks['RANK_' .. mw.ustring.upper(eachPropClaim.rank)]  
or (mw.wikibase.entity.claimRanks['RANK_' .. mw.ustring.upper(bestClaim.rank)] < mw.wikibase.entity.claimRanks['RANK_' .. mw.ustring.upper(eachPropClaim.rank)] and not after) then
or (mw.wikibase.entity.claimRanks['RANK_' .. mw.ustring.upper(bestClaim.rank)] < mw.wikibase.entity.claimRanks['RANK_' .. mw.ustring.upper(eachPropClaim.rank)] and not after) then
bestClaim = eachPropClaim
bestClaim = eachPropClaim
end
end