Modul:Wikidata/Sorters/date

require 'Modul:No globals'

local p = {}

local lib = require 'Modul:Wikidata/lib'
local Formatters = require 'Modul:Wikidata/Formatters'

local function getValues(qualifiers)
	local Values = {}
	if qualifiers then
		for key, array in pairs(lib.props) do
			for _, prop in ipairs(array) do
				for _, snak in ipairs(qualifiers[prop] or {}) do
					if lib.IsSnakValue(snak) then
						Values[key] = Formatters.getRawValue(snak)
						break
					end
				end
			end
		end
	end
	return Values
end

function p.isCompleteStatement(statement)
	local Values = getValues(statement.qualifiers)
	return (Values.begin or Values.ending) and true
end

function p.mayCompareStatement(statement)
	return true
end

function p.compareStatements(first, second)
	local FirstValues = getValues(first.qualifiers)
	local SecondValues = getValues(second.qualifiers)
	if FirstValues.begin and SecondValues.begin then
		if FirstValues.begin ~= SecondValues.begin then
			return lib.simpleCompare(FirstValues.begin, SecondValues.begin)
		end
		if FirstValues.ending and SecondValues.ending then
			return lib.simpleCompare(FirstValues.ending, SecondValues.ending)
		end
		if FirstValues.ending then
			return -1
		elseif SecondValues.ending then
			return 1
		else
			return 0
		end
	end
	if FirstValues.ending and SecondValues.ending then
		if FirstValues.ending == SecondValues.ending then
			if FirstValues.begin then
				return 1
			elseif SecondValues.begin then
				return -1
			else
				return 0
			end
		end
	end
	if FirstValues.begin and SecondValues.ending then
		return lib.simpleCompare(FirstValues.begin, SecondValues.ending)
	end
	if FirstValues.ending and SecondValues.begin then
		if FirstValues.ending > SecondValues.begin then
			return 1
		else
			return -1
		end
	end
	return lib.simpleCompare(FirstValues.ending, SecondValues.ending)
end

return p

Zdroj datcs.wikipedia.org
Originálcs.wikipedia.org/wiki/Modul:Wikidata/Sorters/date
Zobrazit sloupec 

Kalkulačka - Výpočet

Výpočet čisté mzdy

Důchodová kalkulačka

Přídavky na dítě

Příspěvek na bydlení

Rodičovský příspěvek

Životní minimum

Hypoteční kalkulačka

Povinné ručení

Banky a Bankomaty

Úrokové sazby, Hypotéky

Směnárny - Euro, Dolar

Práce - Volná místa

Úřad práce, Mzda, Platy

Dávky a příspěvky

Nemocenská, Porodné

Podpora v nezaměstnanosti

Důchody

Investice

Burza - ČEZ

Dluhopisy, Podílové fondy

Ekonomika - HDP, Mzdy

Kryptoměny - Bitcoin, Ethereum

Drahé kovy

Zlato, Investiční zlato, Stříbro

Ropa - PHM, Benzín, Nafta, Nafta v Evropě

Podnikání

Města a obce, PSČ

Katastr nemovitostí

Katastrální úřady

Ochranné známky

Občanský zákoník

Zákoník práce

Stavební zákon

Daně, formuláře

Další odkazy

Auto - Cena, Spolehlivost

Registr vozidel - Technický průkaz, eTechničák

Finanční katalog

Volby, Mapa webu

English version

Czech currency

Prague stock exchange


Ochrana dat, Cookies

 

Copyright © 2000 - 2024

Kurzy.cz, spol. s r.o., AliaWeb, spol. s r.o.