Content deleted Content added
Increased efficiency a bit |
Fix for decades/centuries/millenniums and other minor edits |
||
Line 211:
-- if precision is tens/hundreds/thousands of years
if precision >= 6 then
-- if unit added then round centuries/millenniums up (e.g. 21st century or 3rd millennium, but 2010s for decade)▼
mayAddCalendar = true
▲ --
if addUnit then
if precision == 6 then
suffix = " millennium"
Line 225 ⟶ 226:
suffix = self:getOrdinalSuffix(yRound) .. suffix
else
-- if no unit added, take the first year of the century/millennium
yRound = math.floor(yDiv) * yFactor▼
-- (e.g. 1901 for 20th century or 2001 for 3rd millennium)
suffix = "s"▼
end
else
-- precision == 8
-- round decades down (e.g. 2010s)
yRound = math.floor(yDiv) * yFactor
if addUnit then
▲ suffix = "s"
end▼
end▼
if not addUnit and sign < 0 then
-- if BCE then compensate for "counting backwards"
-- (e.g. -2019 for 2010s BCE, -2000 for 20th century BCE or -3000 for 3rd millennium BCE)
yRound = yRound + yFactor - 1
end
else
Line 415 ⟶ 429:
function State:getRawValue(snak)
if snak.snaktype == 'value' and snak.datavalue.type == 'wikibase-entityid' then
return "Q" .. snak.datavalue.value['numeric-id']
elseif snak.snaktype == 'somevalue' then▼
elseif snak.snaktype == 'novalue' then▼
else
return self:getValue(snak, false, false)
Line 424 ⟶ 441:
function State:snakEqualsValue(snak, value)
▲ local snakValue = self:getRawValue(snak)
▲ if snakValue and snak.datavalue.type == 'wikibase-entityid' then value = value:upper() end
▲ return snakValue == value
▲ elseif snak.snaktype == 'somevalue' then
▲ if value == " " then -- single space represents 'somevalue'
▲ end
▲ elseif snak.snaktype == 'novalue' then
▲ if value == "" then -- empty value represents 'novalue'
▲ end
end
Line 627 ⟶ 628:
if entity and entity.claims then claims = entity.claims[propertyID] end
if claims then
for
rankPos = _:convertRank(v.rank)
if _:rankMatches(rankPos) then
Line 652 ⟶ 653:
_ = _ or State.new()
local entity, propertyID, propertyValue, qualifierID, claims, qualifiers, rankPos, outValue, outInter,
local done = false
local nextArg = mw.text.trim(args[1] or "")
local nextIndex = 2
Line 693 ⟶ 696:
if entity and entity.claims then claims = entity.claims[propertyID] end
if claims then
for
rankPos = _:convertRank(v.rank)
if propertyValue == nil or _:snakEqualsValue(v.mainsnak, propertyValue) then
Line 699 ⟶ 702:
outValue = nil
outInter = nil
if _.propertyWithQualifier then
Line 708 ⟶ 711:
if v.qualifiers then qualifiers = v.qualifiers[qualifierID] end
if (not _.propertyWithQualifier or outValue) and qualifiers then
-- get a bare qualifier, or
for
outInter = _:getValue(v2, _.withUnit, _.linked)
if outInter then
Line 718 ⟶ 721:
end
else
end
end
Line 725 ⟶ 728:
if _.propertyWithQualifier and outValue then
if
outValue = outValue ..
end
|