Modul:Jahrestag: Unterschied zwischen den Versionen

Keine Bearbeitungszusammenfassung
K (Entfernte den Schutz von „Modul:Jahrestag“)
 
(55 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
local p = {}
local p = {}
local c = require( "Module:Common" )
local c = require("Modul:Common")
local str = require("Modul:String")
local arr = require("Modul:Array")


function p.Kalender( frame )
function p.Kalender(frame)
pf = frame:getParent()
local args = frame:getParent().args
args = pf.args
local title = mw.title.getCurrentTitle().text
pt = mw.title.getCurrentTitle().text
local ma = str.split(title, '.')
local day, month, month_nr
local md, mu -- month down/month up
if c.len(ma) == 1 then
day = 0
month = ma[1]
else
day = str.rstrip(ma[1])
month = str.lstrip(ma[2])
end
t = [[
local months=c.getMonthList()
<table class="wikitable">
for i, v in ipairs(months) do
  <tr>
if v == month then
     <th>one</th>
month_nr = i
    <th>two</th>
end
  </th>
end
  <tr>
 
     <td>one</td>
local t='<table class="wikitable monatsbox">'..
     <td>two</td>
'<tr>'
  </tr>
</table>'
-- Von Januar aus wieder auf Dezember springen
]]
md = month_nr - 1
--Jahrzehnt(year)..
if md == 0 then
--Jahre(year)..
md = 12
--'</p></div>'
end
-- Der md (month-down-button) verlinkt zum nächsten Tag der existiert
     t=t..'<th>[['
    if day ~= 0 then
    mds = day..'. '..months[md]
    for i = 0, 2 do
      mds = tostring(day-i)..'. '..months[md]
    if mw.title.new(mds).exists then
    break
    end
    end
    t=t..mds
    else
    t=t..':Kategorie:'..months[md]
    end
    t=t..'|◄]]</th>'..
        '<th colspan="5">[[:Kategorie:'..month..'|'..month..']]</th>'
   
    -- Von Dezember aus wieder auf Januar springen
    mu = month_nr + 1
if mu == 13 then
mu = 1
end
-- Der mu (month-up-button) verlinkt zum nächsten Tag der existiert
     t=t..'<th>[['
     if day ~= 0 then
    mus = day..'. '..months[mu]
    for i = 0, 2 do
    mus = tostring(day-i)..'. '..months[mu]
    if mw.title.new(mus).exists then
    break
    end
    end
    t=t..mus
else
    t=t..':Kategorie:'..months[mu]
    end
    t=t..'|►]]</th>'
-- A weng ungampert, aber funktioniert ;-)
t=t..p.woche(1, month) ..
p.woche(8, month) ..
p.woche(15, month) ..
p.woche(22, month) ..
p.woche(29, month)
t=t..'</table>'
return t
return t
end  
end  


function Jahre(year)
function p.woche(day, month)
t = '[['..tostring(year-1)..'|◄]] | ' ..
local a = 6
'[['..tostring(year-5)..']] | ' ..
if day == 29 then
'[['..tostring(year-4)..']] | ' ..
if arr.contains({'April', 'Juni', 'September', 'November'}, month) then
'[['..tostring(year-3)..']] | ' ..
a=1
'[['..tostring(year-2)..']] | ' ..
elseif month == 'Februar' then
'[['..tostring(year-1)..']] | ' ..
a=0
'[['..tostring(year)..']] | ' ..
else
'[['..tostring(year+1)..']] | ' ..
a=2
'[['..tostring(year+2)..']] | ' ..
end
'[['..tostring(year+3)..']] | ' ..
end
'[['..tostring(year+4)..']] | ' ..
'[['..tostring(year+5)..']] | ' ..
local t = '<tr>'
'[['..tostring(year+1)..'|►]]<br>'
for i=day, day + a do
    t = t .. '<td align="right">[['..i..'. ' .. month .. '|' .. i .. ']]</td>'
end
t = t..'</tr>'
return t
return t
end
end


function Jahrzehnt(year)
t = '[['..tostring(year-10)..'|◄]] | '..
    'Jahrzehnt | '..
'[['..tostring(year+10)..'|►]]<br>'
return t
end
return p
return p

Aktuelle Version vom 27. Oktober 2025, 08:03 Uhr

p.Kalender

Diese Funktion bildet einen Monatstage-Kasten ab und wird per #invoke: eingebunden. Der Monat wird dem Lemma entnommen, weshalb diese Funktion keine Attribute benötigt.

p.woche

Eine nur von p.Kalender genutzte Funktion, welche die Anzahl der Wochentage für den jeweiligen Monat berechnet.


local p = {}
local c = require("Modul:Common")
local str = require("Modul:String")
local arr = require("Modul:Array")

function p.Kalender(frame)
	local args = frame:getParent().args
	local title = mw.title.getCurrentTitle().text
	local ma = str.split(title, '.')
	local day, month, month_nr
	local md, mu	-- month down/month up
	if c.len(ma) == 1 then
		day = 0
		month = ma[1]
	else
		day = str.rstrip(ma[1])
		month = str.lstrip(ma[2])
	end
	
	local months=c.getMonthList()
	for i, v in ipairs(months) do
		if v == month then
			month_nr = i
		end
	end

	local t='<table class="wikitable monatsbox">'..
		'<tr>'
	
	-- Von Januar aus wieder auf Dezember springen	
	md = month_nr - 1
	if md == 0 then
		md = 12
	end
	
	-- Der md (month-down-button) verlinkt zum nächsten Tag der existiert
    t=t..'<th>[['
    if day ~= 0 then
    	mds = day..'. '..months[md]
    	for i = 0, 2 do
    	   	mds = tostring(day-i)..'. '..months[md]
    		if mw.title.new(mds).exists then
    			break
    		end
    	end
    	t=t..mds
    else
    	t=t..':Kategorie:'..months[md]
    end
    t=t..'|◄]]</th>'..
         '<th colspan="5">[[:Kategorie:'..month..'|'..month..']]</th>'
    
    -- Von Dezember aus wieder auf Januar springen
    mu = month_nr + 1
	if mu == 13 then
		mu = 1
	end
	
	-- Der mu (month-up-button) verlinkt zum nächsten Tag der existiert
    t=t..'<th>[['
    if day ~= 0 then
    	mus = day..'. '..months[mu]
    	for i = 0, 2 do
    		mus = tostring(day-i)..'. '..months[mu]
    		if mw.title.new(mus).exists then
    			break
    		end
    	end
    	t=t..mus
	else
    	t=t..':Kategorie:'..months[mu]
    end
    t=t..'|►]]</th>'
	
	-- A weng ungampert, aber funktioniert ;-)
	t=t..p.woche(1, month) ..
		 p.woche(8, month) ..
		 p.woche(15, month) ..
		 p.woche(22, month) ..
		 p.woche(29, month)
	t=t..'</table>'
	return t
end 

function p.woche(day, month)
	local a = 6
	if day == 29 then
		if arr.contains({'April', 'Juni', 'September', 'November'}, month) then
			a=1
		elseif month == 'Februar' then
			a=0
		else 
			a=2
		end
	end
	
	local t = '<tr>'
	for i=day, day + a do
    	t = t .. '<td align="right">[['..i..'. ' .. month .. '|' .. i .. ']]</td>'
	end
	t = t..'</tr>'
	return t
end

return p