localp={}functionp.formatPropertyWithMostRecentClaimAndIndicator(context,options)if(notcontext)thenerror('context not specified');end;if(notoptions)thenerror('options not specified');end;if(notoptions.entity)thenerror('options.entity missing');end;localclaims;ifoptions.propertythen-- Пролучаем все claims независимо от рангаclaims=context.selectClaims(options,options.property..'[rank:normal,rank:preferred]');endifclaims==nilthenreturn''end-- Ищем claim с максимальным значением P585 и форматируем его в outlocalmaxTimestamp=0;localmostRecentClaim;fori,claiminipairs(claims)doif(claim.qualifiersandclaim.qualifiers.P585)then-- обрабатываем только claims с указанным P585if(maxTimestamp<context.parseTimeFromSnak(claim.qualifiers.P585[1]))thenmaxTimestamp=context.parseTimeFromSnak(claim.qualifiers.P585[1])mostRecentClaim=claimendendendif(notmostRecentClaim)then-- нет ни одного claim с указанным P585returncontext.formatPropertyDefault(context,options)endlocalout=context.formatStatement(options,mostRecentClaim)ifout~=''then-- Ищем claim со значением P585 сразу после максимального и запоминаем его в secondMostRecentValuelocalsecondMostRecentTimestamp=0;localsecondMostRecentValue=0;fori,claiminipairs(claims)doif(claim.qualifiersandclaim.qualifiers.P585)then-- обрабатываем только claims с указанным P585localtimestamp=context.parseTimeFromSnak(claim.qualifiers.P585[1])if(secondMostRecentTimestamp<timestampandmaxTimestamp>timestamp)thensecondMostRecentTimestamp=timestampsecondMostRecentValue=tonumber(claim.mainsnak.datavalue.value.amount)endendendif(secondMostRecentValue~=0)then-- если предыдущее значение нашлосьif(secondMostRecentValue<tonumber(mostRecentClaim.mainsnak.datavalue.value.amount))thenout='<span style="color: #0c0; font-size: larger;">▲</span>'..outelseout='<span style="color: red; font-size: larger;">▼</span>'..outendendifoptions.beforethenout=options.before..outendifoptions.afterthenout=out..options.afterendendreturnoutendfunctionp.formatQuantityWithDateClaim(context,options,statement)localsnak=context.formatSnak(options,statement.mainsnak)--Dateif(statement.qualifiersandstatement.qualifiers.P585)thensnak=snak..' ('..context.formatSnak(options,statement.qualifiers.P585[1])..')'end--Referencesif(options.references)thensnak=snak..context.formatRefs(options,statement);endreturnsnakendreturnp