<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://www.helmstedt-wiki.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3AWikidata%2FTime</id>
	<title>Modul:Wikidata/Time - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://www.helmstedt-wiki.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3AWikidata%2FTime"/>
	<link rel="alternate" type="text/html" href="https://www.helmstedt-wiki.de/index.php?title=Modul:Wikidata/Time&amp;action=history"/>
	<updated>2026-07-06T23:54:22Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Helmstedt-Wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://www.helmstedt-wiki.de/index.php?title=Modul:Wikidata/Time&amp;diff=10508&amp;oldid=prev</id>
		<title>Wikiadmin: Die Seite wurde neu angelegt: „--[=[ Wikidata/Time 2022-10-28 Module for processing wikidata time information  Author: Vollbracht  == for use in other modules == * service	object representing a wikidata time property 			fields:	year, month, day, hour, min, sec, 					precision, timezone, calendarmodel 			constructor: 				Time:new(value)		processes snack.datavalue.value e.g. 			method: 				Time:format(fmtStr)		string representation for time object 				Time:qualified(snak)	snak and qualif…“</title>
		<link rel="alternate" type="text/html" href="https://www.helmstedt-wiki.de/index.php?title=Modul:Wikidata/Time&amp;diff=10508&amp;oldid=prev"/>
		<updated>2026-07-04T16:33:43Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „--[=[ Wikidata/Time 2022-10-28 Module for processing wikidata time information  Author: Vollbracht  == for use in other modules == * service	object representing a wikidata time property 			fields:	year, month, day, hour, min, sec, 					precision, timezone, calendarmodel 			constructor: 				Time:new(value)		processes snack.datavalue.value e.g. 			method: 				Time:format(fmtStr)		string representation for time object 				Time:qualified(snak)	snak and qualif…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[=[ Wikidata/Time 2022-10-28&lt;br /&gt;
Module for processing wikidata time information&lt;br /&gt;
&lt;br /&gt;
Author: Vollbracht&lt;br /&gt;
&lt;br /&gt;
== for use in other modules ==&lt;br /&gt;
* service	object representing a wikidata time property&lt;br /&gt;
			fields:	year, month, day, hour, min, sec,&lt;br /&gt;
					precision, timezone, calendarmodel&lt;br /&gt;
			constructor:&lt;br /&gt;
				Time:new(value)		processes snack.datavalue.value e.g.&lt;br /&gt;
			method:&lt;br /&gt;
				Time:format(fmtStr)		string representation for time object&lt;br /&gt;
				Time:qualified(snak)	snak and qualification state&lt;br /&gt;
				Time:isLessthan(time)	comparator method&lt;br /&gt;
				Time:equals(time)		comparator method&lt;br /&gt;
* service.LT(a, b)			comparator function for table.sort e.g.&lt;br /&gt;
* service.equals(a, b)		comparator function&lt;br /&gt;
* service.timify(values)	table of time objects by table of values&lt;br /&gt;
&lt;br /&gt;
== for use in templates ==&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Wikidata/Time|now|&amp;lt;format string&amp;gt;}}	current system time&lt;br /&gt;
			(mainly for testing purposes;&lt;br /&gt;
			 format string optional: defaults to wikidata time string format)&lt;br /&gt;
&lt;br /&gt;
]=]&lt;br /&gt;
	&lt;br /&gt;
--Module globals&lt;br /&gt;
&lt;br /&gt;
local _, GeneralTime = pcall(require, &amp;quot;Modul:Time&amp;quot;)&lt;br /&gt;
local constant = GeneralTime.constant&lt;br /&gt;
local pointOfTime = GeneralTime.point&lt;br /&gt;
&lt;br /&gt;
local p = { service={&lt;br /&gt;
	-- more selective variant to &amp;#039;(.)(%d+)%-(%d+)%-(%d+)T(%d+):(%d+):(%d+)Z&amp;#039;:&lt;br /&gt;
	MATCHING = &amp;#039;(.)(%d+)%-([0-1]%d)%-([0-3]%d)T([0-2]%d):([0-6]%d):([0-6]%d)Z&amp;#039;,&lt;br /&gt;
	PRECISIONLEVEL = constant.PRECISIONLEVEL,&lt;br /&gt;
	DEFAULTFORMAT = constant.DEFAULTFORMAT,&lt;br /&gt;
	PoT=&amp;#039;point of time&amp;#039;&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
local _, DateTime = pcall(require, &amp;quot;Modul:DateTime&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
--------------------------- local functions -----------------------------&lt;br /&gt;
&lt;br /&gt;
--------------------------- service functions -----------------------------&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	constructor&lt;br /&gt;
	generates a Time object&lt;br /&gt;
	parameters:&lt;br /&gt;
		source:	(optional) table of possible time informations as of&lt;br /&gt;
				mw.wikibase.getBestStatements(a, b)[1].mainsnak.datavalue.value&lt;br /&gt;
				current system time if nil&lt;br /&gt;
				NO MANDANTORY INFOS IN TABLE! OBJECT MAY CONTAIN NO TIME DATA!&lt;br /&gt;
]]&lt;br /&gt;
function p.service:new(source)&lt;br /&gt;
	mw.log(source)&lt;br /&gt;
	mw.log(type(source))&lt;br /&gt;
	-- time object is UTC system time if no source specified&lt;br /&gt;
	if not source or source == &amp;#039;&amp;#039; then&lt;br /&gt;
		return pointOfTime:new()&lt;br /&gt;
	end&lt;br /&gt;
	if type(source) == &amp;quot;table&amp;quot; then&lt;br /&gt;
		mw.logObject(source, &amp;#039;from table&amp;#039;)&lt;br /&gt;
		local ts = source[&amp;quot;time&amp;quot;]&lt;br /&gt;
		if not ts then return pointOfTime:new(source) end&lt;br /&gt;
		o = {}&lt;br /&gt;
		setmetatable(o, {__index = pointOfTime})&lt;br /&gt;
		self.__index = self&lt;br /&gt;
		o.era, o.year, o.month, o.day, o.hour, o.min, o.sec&lt;br /&gt;
			= ts:match(p.service.MATCHING)&lt;br /&gt;
		o.year = tonumber(o.year)&lt;br /&gt;
		o.month = tonumber(o.month)&lt;br /&gt;
		o.day = tonumber(o.day)&lt;br /&gt;
		o.hour = tonumber(o.hour)&lt;br /&gt;
		o.min = tonumber(o.min)&lt;br /&gt;
		o.sec = tonumber(o.sec)&lt;br /&gt;
		o.precision = source.precision&lt;br /&gt;
		o.timezone = source.timezone&lt;br /&gt;
		o.calendarmodel = source.calendarmodel&lt;br /&gt;
		o.__tostring=function()&lt;br /&gt;
			return o:format()&lt;br /&gt;
		end&lt;br /&gt;
	elseif type(source) == &amp;#039;string&amp;#039; then return pointOfTime:new(source) end&lt;br /&gt;
	return o&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	Time:qualified(Statement)&lt;br /&gt;
	Statement and its qualification state&lt;br /&gt;
	parameters:&lt;br /&gt;
		Statement	a Statement that is to be qualified&lt;br /&gt;
	returns:	Statement, true		if this time qualifies the snack&lt;br /&gt;
				Statement, false	if Statement is independent from this time&lt;br /&gt;
				nil, false			if this time disqualifies the snack&lt;br /&gt;
				nil, true			if Statement is nil (Ex falso quodlibet)&lt;br /&gt;
]]&lt;br /&gt;
p.service.qualified = function(this, Statement)&lt;br /&gt;
	if not snack then return nil, true end&lt;br /&gt;
	if type(Statement) ~= &amp;#039;table&amp;#039; then return Statement, false end&lt;br /&gt;
	if not Statement.qualifiers then return Statement, false end&lt;br /&gt;
	local hasCriteria = false&lt;br /&gt;
	-- point of time&lt;br /&gt;
	for _, pot in ipairs(Statement.qualifiers.P585) do&lt;br /&gt;
		local comp = p.service:new(pot.datavalue.value)&lt;br /&gt;
		if this ~= comp then return nil, false end&lt;br /&gt;
		hasCriteria = true;&lt;br /&gt;
	end&lt;br /&gt;
	-- start time&lt;br /&gt;
	for _, pot in ipairs(Statement.qualifiers.P580) do&lt;br /&gt;
		local comp = p.service:new(pot.datavalue.value)&lt;br /&gt;
		if this &amp;lt; comp then return nil, false end&lt;br /&gt;
		hasCriteria = true;&lt;br /&gt;
	end&lt;br /&gt;
	-- end time&lt;br /&gt;
	for _, pot in ipairs(Statement.qualifiers.P582) do&lt;br /&gt;
		local comp = p.service:new(pot.datavalue.value)&lt;br /&gt;
		if comp &amp;lt; this then return nil, false end&lt;br /&gt;
		hasCriteria = true;&lt;br /&gt;
	end&lt;br /&gt;
	return Statement, hasCriteria&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	Time:getFiltered(statemens)&lt;br /&gt;
	new claim list without time disqualified claims&lt;br /&gt;
	parameters:&lt;br /&gt;
		statemens	data source as of mw.wikidata.getBestStatements&lt;br /&gt;
	returns:	refined claimlist&lt;br /&gt;
]]&lt;br /&gt;
p.service.getFiltered = function(this, statements)&lt;br /&gt;
	local result = {}&lt;br /&gt;
	for _, v in ipairs(claimlist) do&lt;br /&gt;
		local tested, tv = this:qualified(v)&lt;br /&gt;
		if tested then table.insert(result, tested) end&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	Time.timify(values)&lt;br /&gt;
	table of time objects by table of values&lt;br /&gt;
	can process statements as of mw.wikidata.getBestStatements(&amp;#039;Q79822&amp;#039;, &amp;#039;P569&amp;#039;)&lt;br /&gt;
	or qualifiers for a statement&lt;br /&gt;
	parameters:&lt;br /&gt;
		values:	table: {&amp;lt;source&amp;gt;, &amp;lt;source&amp;gt;, ...}&lt;br /&gt;
				&amp;lt;source&amp;gt;: (requirements as of time:new() source parameter)&lt;br /&gt;
	returns:	table:	{&amp;lt;time object&amp;gt;, &amp;lt;time object&amp;gt;, ...}&lt;br /&gt;
						Time objects of &amp;lt;source&amp;gt;-elements that could be&lt;br /&gt;
						converted are in this result table. The others are&lt;br /&gt;
						just ignored. Hence contains initialized time&lt;br /&gt;
						objects only.&lt;br /&gt;
				nil if result table empty&lt;br /&gt;
]]&lt;br /&gt;
p.service.timify = function(values)&lt;br /&gt;
	local result = {}&lt;br /&gt;
	for _, v in ipairs(values) do&lt;br /&gt;
		local value = v&lt;br /&gt;
		if value.mainsnak then value = value.mainsnak end&lt;br /&gt;
		if value.datavalue then value = value.datavalue end&lt;br /&gt;
		if value.value then value = value.value end&lt;br /&gt;
		local t = service.time:new(v)&lt;br /&gt;
		if t.year then table.insert(result, t) end&lt;br /&gt;
	end&lt;br /&gt;
	if #result == 0 then return nil end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	Time.filtered(claimlist, timeStr)&lt;br /&gt;
	new claim list without time disqualified claims&lt;br /&gt;
	parameters:&lt;br /&gt;
		claimlist	data source as of mw.wikidata.getBestStatements&lt;br /&gt;
		timeStr		time given by user&lt;br /&gt;
	returns:	refined claimlist&lt;br /&gt;
]]&lt;br /&gt;
p.service.filtered = function(statements, timeStr)&lt;br /&gt;
	local myTime = p.service:new(timeStr)&lt;br /&gt;
	return myTime:getFiltered(statements)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------- template functions -----------------------------&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	{{#invoke:Wikidata/Time|now|&amp;lt;format string&amp;gt;}}&lt;br /&gt;
	current system time&lt;br /&gt;
]]&lt;br /&gt;
p.now = function(frame)&lt;br /&gt;
	return p.service:new():format(frame.args[1])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local testLine = function(a, b, c)&lt;br /&gt;
	local result = &amp;#039;&amp;lt;tr style=&amp;quot;background-color:&amp;#039;&lt;br /&gt;
	if type(b) == &amp;#039;boolean&amp;#039; then if b then b = &amp;#039;true&amp;#039; else b = &amp;#039;false&amp;#039; end&lt;br /&gt;
	elseif b == nil then b = &amp;#039;nil&amp;#039;&lt;br /&gt;
	elseif type(b) == &amp;#039;table&amp;#039; then&lt;br /&gt;
		local t = b.format&lt;br /&gt;
		if t then b = t(b) end&lt;br /&gt;
	end&lt;br /&gt;
	if type(c) == &amp;#039;boolean&amp;#039; then if c then c = &amp;#039;true&amp;#039; else c = &amp;#039;false&amp;#039; end&lt;br /&gt;
	elseif c == nil then c = &amp;#039;nil&amp;#039;&lt;br /&gt;
	elseif type(c) == &amp;#039;table&amp;#039; then&lt;br /&gt;
		local t = c.format&lt;br /&gt;
		if t then c = t(c) end&lt;br /&gt;
	end&lt;br /&gt;
	if b == c then result = result .. &amp;#039;#4f4&amp;quot;&amp;gt;&amp;#039;&lt;br /&gt;
	else result = result .. &amp;#039;#f44&amp;quot;&amp;gt;&amp;#039; end&lt;br /&gt;
	return	result .. &amp;#039;&amp;lt;td&amp;gt;&amp;#039; .. a .. &amp;#039;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;#039; .. b .. &amp;#039;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;#039; .. c&lt;br /&gt;
		..	&amp;#039;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.test = function()&lt;br /&gt;
	local result = &amp;#039;&amp;lt;table class=&amp;quot;wikitable&amp;quot;&amp;gt;&amp;#039;&lt;br /&gt;
	local a = p.service:new(&amp;#039;1.3.2000&amp;#039;)&lt;br /&gt;
	mw.logObject(a)&lt;br /&gt;
	result = result .. testLine(&amp;quot;a:format(&amp;#039;mm-dd&amp;#039;)&amp;quot;, a:format(&amp;#039;mm-dd&amp;#039;), &amp;#039;03-01&amp;#039;)&lt;br /&gt;
	local b = constant.STARTOFGREGORIAN&lt;br /&gt;
	result = result .. testLine(&amp;quot;a, b&amp;quot;, a, b)&lt;br /&gt;
	result = result .. testLine(&amp;quot;a &amp;lt; b&amp;quot;, a &amp;lt; b, false)&lt;br /&gt;
	result = result .. testLine(&amp;quot;a &amp;gt; b&amp;quot;, a &amp;gt; b, true)&lt;br /&gt;
	result = result .. testLine(&amp;quot;a == b&amp;quot;, a == b, false)&lt;br /&gt;
	result = result .. testLine(&amp;quot;a ~= b&amp;quot;, a ~= b, true)&lt;br /&gt;
	a = p.service:new(&amp;#039;1582-08-15&amp;#039;)&lt;br /&gt;
	result = result .. testLine(&amp;quot;a, b&amp;quot;, a, b)&lt;br /&gt;
	result = result .. testLine(&amp;quot;a &amp;lt; b&amp;quot;, a &amp;lt; b, false)&lt;br /&gt;
	result = result .. testLine(&amp;quot;a == b&amp;quot;, a == b, true)&lt;br /&gt;
	result = result .. testLine(&amp;quot;a ~= b&amp;quot;, a ~= b, false)&lt;br /&gt;
	a = p.service:new()&lt;br /&gt;
	result = result .. testLine(&amp;quot;today&amp;quot;, a:format(&amp;#039;d.m.yyyy&amp;#039;), &amp;#039;2.11.2022&amp;#039;)&lt;br /&gt;
	result = result .. testLine(&amp;quot;day of the week&amp;quot;, a:dayOfTheWeek(), 4)&lt;br /&gt;
	result = result .. testLine(&amp;quot;day of the week&amp;quot;, b:dayOfTheWeek(), 2)&lt;br /&gt;
	a = p.service:new(&amp;#039;1582-08-04&amp;#039;)&lt;br /&gt;
	result = result .. testLine(&amp;quot;day of the week&amp;quot;, a:dayOfTheWeek(), 1)&lt;br /&gt;
	return result .. &amp;#039;&amp;lt;/table&amp;gt;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
</feed>