Přeskočit na obsah

Modul:Wikidata/Sorters/date

Tato stránka je zamčena
Z Wikipedie, otevřené encyklopedie
require'Modul:No globals'

localp={}

locallib=require'Modul:Wikidata/lib'
localFormatters=require'Modul:Wikidata/Formatters'

localfunctiongetValues(qualifiers)
localValues={}
ifqualifiersthen
forkey,arrayinpairs(lib.props)do
for_,propinipairs(array)do
for_,snakinipairs(qualifiers[prop]or{})do
iflib.IsSnakValue(snak)then
Values[key]=Formatters.getRawValue(snak)
break
end
end
end
end
end
returnValues
end

functionp.isCompleteStatement(statement)
localValues=getValues(statement.qualifiers)
return(Values.beginorValues.ending)andtrue
end

functionp.mayCompareStatement(statement)
returntrue
end

functionp.compareStatements(first,second)
localFirstValues=getValues(first.qualifiers)
localSecondValues=getValues(second.qualifiers)
ifFirstValues.beginandSecondValues.beginthen
ifFirstValues.begin~=SecondValues.beginthen
returnlib.simpleCompare(FirstValues.begin,SecondValues.begin)
end
ifFirstValues.endingandSecondValues.endingthen
returnlib.simpleCompare(FirstValues.ending,SecondValues.ending)
end
ifFirstValues.endingthen
return-1
elseifSecondValues.endingthen
return1
else
return0
end
end
ifFirstValues.endingandSecondValues.endingthen
ifFirstValues.ending==SecondValues.endingthen
ifFirstValues.beginthen
return1
elseifSecondValues.beginthen
return-1
else
return0
end
end
end
ifFirstValues.beginandSecondValues.endingthen
returnlib.simpleCompare(FirstValues.begin,SecondValues.ending)
end
ifFirstValues.endingandSecondValues.beginthen
ifFirstValues.ending>SecondValues.beginthen
return1
else
return-1
end
end
returnlib.simpleCompare(FirstValues.ending,SecondValues.ending)
end

returnp