Moduł:Wikidane/format/latestPublication

 Dokumentacja modułu [stwórz] [odśwież]
local formatQualifiers = require("Moduł:Wikidane/format/qualifiers")
local resources = {
	naked = { naked = true },
	format = "%s<br /><small>(%s)</small>",
}

return {

options = {
	"bez daty",
	default = {
		["bez daty"] = "Brak daty wydania",
	}
},

scope = "props",

format = function(props, options)
	local prop = false
	local time = false
	for i, p in ipairs(props) do
		local p577 = formatQualifiers.MAXTIME(p, resources.naked, "P577")
		local t = p577 and (p577.snaktype == "value") and p577.datavalue.value.time
		if not prop then
			prop = p
			time = t
		elseif time and t and (time < t) then
			prop = p
			time = t
		elseif not time and t then
			prop = p
			time = t
		end
	end

	local stime = formatQualifiers.MAXTIME(prop, {}, "P577") or options["bez daty"]
	if prop and prop.mainsnak then
		local text = require("Moduł:Wikidane/format/snak").format(prop.mainsnak, options)
		return mw.ustring.format(resources.format, text, stime)
	end
end,
 
}