<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="nb">
	<id>https://www.wikisida.no/index.php?action=history&amp;feed=atom&amp;title=Modul%3AWikidataAlder</id>
	<title>Modul:WikidataAlder - Sideversjonshistorikk</title>
	<link rel="self" type="application/atom+xml" href="https://www.wikisida.no/index.php?action=history&amp;feed=atom&amp;title=Modul%3AWikidataAlder"/>
	<link rel="alternate" type="text/html" href="https://www.wikisida.no/index.php?title=Modul:WikidataAlder&amp;action=history"/>
	<updated>2026-04-15T10:35:52Z</updated>
	<subtitle>Versjonshistorikk for denne siden på wikien</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.wikisida.no/index.php?title=Modul:WikidataAlder&amp;diff=1865&amp;oldid=prev</id>
		<title>Wikisida: Én sideversjon ble importert</title>
		<link rel="alternate" type="text/html" href="https://www.wikisida.no/index.php?title=Modul:WikidataAlder&amp;diff=1865&amp;oldid=prev"/>
		<updated>2026-02-08T15:18:52Z</updated>

		<summary type="html">&lt;p&gt;Én sideversjon ble importert&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;nb&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Eldre sideversjon&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Sideversjonen fra 8. feb. 2026 kl. 15:18&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;nb&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(Ingen forskjell)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key c1wiki:diff:1.41:old-1864:rev-1865 --&gt;
&lt;/table&gt;</summary>
		<author><name>Wikisida</name></author>
	</entry>
	<entry>
		<id>https://www.wikisida.no/index.php?title=Modul:WikidataAlder&amp;diff=1864&amp;oldid=prev</id>
		<title>nb&gt;Haros: Tar ibruk alder på angjeldende tid (P3629) når den finnes, og alternativet er ingen alder. Spores i kategorien Sider som bruker P3629</title>
		<link rel="alternate" type="text/html" href="https://www.wikisida.no/index.php?title=Modul:WikidataAlder&amp;diff=1864&amp;oldid=prev"/>
		<updated>2025-06-09T08:12:02Z</updated>

		<summary type="html">&lt;p&gt;Tar ibruk alder på angjeldende tid (P3629) når den finnes, og alternativet er ingen alder. Spores i kategorien Sider som bruker P3629&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Ny side&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local Date = require(&amp;#039;Module:Date&amp;#039;)._Date&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function okProperty(prop)&lt;br /&gt;
	-- Sjekk at prop finnes&lt;br /&gt;
	if prop&lt;br /&gt;
		and prop[&amp;#039;mainsnak&amp;#039;]&lt;br /&gt;
		and prop[&amp;#039;mainsnak&amp;#039;][&amp;#039;datavalue&amp;#039;] &lt;br /&gt;
		and prop[&amp;#039;mainsnak&amp;#039;][&amp;#039;datavalue&amp;#039;][&amp;#039;value&amp;#039;]&lt;br /&gt;
		and prop[&amp;#039;mainsnak&amp;#039;][&amp;#039;datavalue&amp;#039;][&amp;#039;value&amp;#039;][&amp;#039;time&amp;#039;]&lt;br /&gt;
		and prop[&amp;#039;mainsnak&amp;#039;][&amp;#039;datavalue&amp;#039;][&amp;#039;value&amp;#039;][&amp;#039;precision&amp;#039;]&lt;br /&gt;
	then &lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function checkForUnknownValue(prop)&lt;br /&gt;
	-- Sjekk om vi har &amp;quot;ukjent verdi&amp;quot;&lt;br /&gt;
	if prop&lt;br /&gt;
		and prop[&amp;#039;mainsnak&amp;#039;]&lt;br /&gt;
		and prop[&amp;#039;mainsnak&amp;#039;][&amp;#039;snaktype&amp;#039;] == &amp;#039;somevalue&amp;#039; &lt;br /&gt;
	then &lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.formatTime(timestamp)&lt;br /&gt;
    local year = tonumber(string.sub(timestamp, 2, 5))&lt;br /&gt;
    local month = tonumber(string.sub(timestamp, 7, 8))&lt;br /&gt;
    local day = tonumber(string.sub(timestamp, 10, 11))&lt;br /&gt;
        if string.sub(timestamp, 1, 1) == &amp;#039;-&amp;#039; then&lt;br /&gt;
        year = 0 - year&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    if year ~= nil and month ~= nil and day ~= nil then&lt;br /&gt;
    	return Date(tonumber(year), tonumber(month), tonumber(day))&lt;br /&gt;
    else &lt;br /&gt;
    	return nil&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function findBestProperty(qv, pv)&lt;br /&gt;
    local entity = mw.wikibase.getEntity(qv)&lt;br /&gt;
    if not entity then&lt;br /&gt;
        return&lt;br /&gt;
    end&lt;br /&gt;
    if not entity[&amp;#039;claims&amp;#039;] or not entity[&amp;#039;claims&amp;#039;][pv] then&lt;br /&gt;
        return&lt;br /&gt;
    end&lt;br /&gt;
    local prop = entity[&amp;#039;claims&amp;#039;][pv]&lt;br /&gt;
    local i = 0&lt;br /&gt;
    local oki = 0&lt;br /&gt;
    while i &amp;lt; #prop do&lt;br /&gt;
        i = i + 1&lt;br /&gt;
        local rank = prop[i][&amp;#039;rank&amp;#039;]&lt;br /&gt;
        if rank == &amp;#039;preferred&amp;#039; then&lt;br /&gt;
            return prop[i]&lt;br /&gt;
        end&lt;br /&gt;
        if rank == &amp;#039;normal&amp;#039; then&lt;br /&gt;
            if oki == 0 then&lt;br /&gt;
                oki = i&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    if oki &amp;gt; 0 then&lt;br /&gt;
        return prop[oki]&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function getDate(frame, action)&lt;br /&gt;
&lt;br /&gt;
	local propertyID&lt;br /&gt;
&lt;br /&gt;
	if action == &amp;#039;born&amp;#039; then&lt;br /&gt;
		propertyID = &amp;#039;P569&amp;#039;&lt;br /&gt;
	elseif action == &amp;#039;died&amp;#039; then&lt;br /&gt;
		propertyID = &amp;#039;P570&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;&amp;#039;, nil, &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local qid = frame.args[1]&lt;br /&gt;
	if qid and qid == &amp;#039;&amp;#039; then&lt;br /&gt;
		qid = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
	local prop = findBestProperty(qid, propertyID)&lt;br /&gt;
	&lt;br /&gt;
	if not prop then&lt;br /&gt;
		return &amp;#039;&amp;#039;;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if checkForUnknownValue(prop) then&lt;br /&gt;
		return &amp;#039;unknown value&amp;#039;, nil, &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if okProperty(prop) then&lt;br /&gt;
		local timestamp = prop[&amp;#039;mainsnak&amp;#039;][&amp;#039;datavalue&amp;#039;][&amp;#039;value&amp;#039;][&amp;#039;time&amp;#039;]&lt;br /&gt;
		local precision = prop[&amp;#039;mainsnak&amp;#039;][&amp;#039;datavalue&amp;#039;][&amp;#039;value&amp;#039;][&amp;#039;precision&amp;#039;]&lt;br /&gt;
		local qualifiers = prop.qualifiers&lt;br /&gt;
		local ageDeath = &amp;#039;&amp;#039;&lt;br /&gt;
		if qualifiers and qualifiers.P3629 then&lt;br /&gt;
			ageDeath = mw.wikibase.formatValues(qualifiers.P3629)&lt;br /&gt;
		end&lt;br /&gt;
		return p.formatTime(timestamp), precision, ageDeath&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;&amp;#039;, nil, &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.alderInfoboks(frame)&lt;br /&gt;
	&lt;br /&gt;
	local timestampBorn, precisionBorn,dummy = getDate(frame, &amp;#039;born&amp;#039;)&lt;br /&gt;
	local timestampDied, precisionDied,ageDeath = getDate(frame, &amp;#039;died&amp;#039;)&lt;br /&gt;
	if ageDeath and ageDeath ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		ageDeath = &amp;quot;[[Kategori:sider som bruker P3629]]&amp;quot;..&amp;#039;(&amp;#039; .. ageDeath .. &amp;#039;)&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	if (timestampBorn == &amp;#039;unknown value&amp;#039; or timestampDied == &amp;#039;unknown value&amp;#039;) then&lt;br /&gt;
		return ageDeath&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (timestampBorn == nil and timestampDied == nil) or precisionBorn == nil then&lt;br /&gt;
		return ageDeath	&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if timestampDied == &amp;#039;&amp;#039; and precisionBorn &amp;gt;= tonumber(11) then&lt;br /&gt;
		local localtime = mw.language.getContentLanguage():formatDate( &amp;#039;Y-m-d&amp;#039;, nil, true )&lt;br /&gt;
		local diff = Date(localtime) - timestampBorn&lt;br /&gt;
		-- capture error&lt;br /&gt;
		if diff == nil then&lt;br /&gt;
			return ageDeath&lt;br /&gt;
		end&lt;br /&gt;
		return mw.text.nowiki(&amp;#039;(&amp;#039; .. diff:age(&amp;#039;y&amp;#039;) .. &amp;#039; år)&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if timestampDied ~= nil and precisionDied ~= nil and (precisionBorn &amp;gt;= tonumber(11) and precisionDied &amp;gt;= tonumber(11)) then&lt;br /&gt;
		local diff = timestampBorn - timestampDied&lt;br /&gt;
		return mw.text.nowiki(&amp;#039;(&amp;#039; .. diff:age(&amp;#039;y&amp;#039;) .. &amp;#039; år)&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return ageDeath&lt;br /&gt;
	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>nb&gt;Haros</name></author>
	</entry>
</feed>