Modul:Jahrestag: Unterschied zwischen den Versionen
Aus FürthWiki
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 30: | Zeile 30: | ||
md = 12 | md = 12 | ||
end | end | ||
t=t..'<th>[['..day..'. '..months[md]..'|◄]]</th>'.. | t=t..'<th>[[' | ||
if day ~= 0 then | |||
t=t..day..'. '..months[md] | |||
else | |||
t=t..'[[:Kategorie:'..months[md]..'|'..months[md]..']]' | |||
end | |||
t=t..'|◄]]</th>'.. | |||
'<th colspan="5">[[:Kategorie:'..month..'|'..month..']]</th>' | '<th colspan="5">[[:Kategorie:'..month..'|'..month..']]</th>' | ||
| Zeile 42: | Zeile 48: | ||
t=t..day..'. '..months[mu] | t=t..day..'. '..months[mu] | ||
else | else | ||
t=t..months[mu] | t=t..'[[:Kategorie:'..months[mu]..'|'..months[mu]..']]' | ||
end | end | ||
t=t..'|►]]</th>' | t=t..'|►]]</th>' | ||
Version vom 22. Januar 2025, 22:15 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( "Module:Common" )
function p.Kalender( frame )
pf = frame:getParent()
args = pf.args
pt = mw.title.getCurrentTitle().text
ma=split(pt, '.')
if #ma == 0 then
day = 0
month = ma[0]
else
day = rtrim(ma[0])
month = ltrim(ma[1])
end
months=getMonthList()
for i, v in ipairs(months) do
if v == month then
month_nr = i
end
end
t='<table class="wikitable monatsbox">'..
'<tr>'
-- Von Januar aus wieder auf Dezember springen
md = month_nr-1
if md == 0 then
md = 12
end
t=t..'<th>[['
if day ~= 0 then
t=t..day..'. '..months[md]
else
t=t..'[[:Kategorie:'..months[md]..'|'..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
t=t..'<th>[['
if day ~= 0 then
t=t..day..'. '..months[mu]
else
t=t..'[[:Kategorie:'..months[mu]..'|'..months[mu]..']]'
end
t=t..'|►]]</th>'
-- A weng ungambert, aber funktioniert ;-)
t=t..Woche(1, month)..
Woche(8, month)..
Woche(15, month)..
Woche(22, month)..
Woche(29, month)
t=t..'</table>'..
'[[Kategorie:'..month..']]'
return t
end
function Woche(d, month)
a=6
if d == 29 then
if contains({'April', 'Juni', 'September', 'November'}, month) then
a=1
elseif month == 'Februar' then
a=0
else
a=2
end
end
t = '<tr>'
for i=d, d+a do
t=t..'<td align="right">[['..i..'. '..month..'|'..i..']]</td>'
end
t = t..'</tr>'
return t
end
return p