Modul:Jahrestag: Unterschied zwischen den Versionen
Aus FürthWiki
Keine Bearbeitungszusammenfassung |
(fix kal.month_names[) |
||
| (14 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
local p = {} | local p = {} | ||
function p.Kalender( frame ) | local com = require("Modul:Common") | ||
local str = require("Modul:String") | |||
local arr = require("Modul:Array") | |||
local kal = require("Modul:Kalender") | |||
ma=split( | |||
if | 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 com.len(ma) == 1 then | |||
day = 0 | day = 0 | ||
month = ma[ | month = ma[1] | ||
else | else | ||
day = | day = str.rstrip(ma[1]) | ||
month = | month = str.lstrip(ma[2]) | ||
end | end | ||
month_nr = kal.month_numbers[month] | |||
t='<table class="wikitable monatsbox">'.. | local t='<table class="wikitable monatsbox">'.. | ||
'<tr>' | |||
-- Von Januar aus wieder auf Dezember springen | -- Von Januar aus wieder auf Dezember springen | ||
md = month_nr-1 | md = month_nr - 1 | ||
if md == 0 then | if md == 0 then | ||
md = 12 | md = 12 | ||
| Zeile 34: | Zeile 34: | ||
t=t..'<th>[[' | t=t..'<th>[[' | ||
if day ~= 0 then | if day ~= 0 then | ||
mds = day..'. '.. | mds = day..'. '..kal.month_names[md] | ||
for i = 0, 2 do | for i = 0, 2 do | ||
mds = tostring(day-i)..'. '.. | mds = tostring(day-i)..'. '..kal.month_names[md] | ||
if mw.title.new(mds).exists then | if mw.title.new(mds).exists then | ||
break | break | ||
| Zeile 43: | Zeile 43: | ||
t=t..mds | t=t..mds | ||
else | else | ||
t=t..':Kategorie:'.. | t=t..':Kategorie:'..kal.month_names[md] | ||
end | end | ||
t=t..'|◄]]</th>'.. | t=t..'|◄]]</th>'.. | ||
| Zeile 49: | Zeile 49: | ||
-- Von Dezember aus wieder auf Januar springen | -- Von Dezember aus wieder auf Januar springen | ||
mu = month_nr+1 | mu = month_nr + 1 | ||
if mu == 13 then | if mu == 13 then | ||
mu = 1 | mu = 1 | ||
| Zeile 57: | Zeile 57: | ||
t=t..'<th>[[' | t=t..'<th>[[' | ||
if day ~= 0 then | if day ~= 0 then | ||
mus = day..'. '.. | mus = day..'. '..kal.month_names[mu] | ||
for i = 0, 2 do | for i = 0, 2 do | ||
mus = tostring(day-i)..'. '.. | mus = tostring(day-i)..'. '..kal.month_names[mu] | ||
if mw.title.new(mus).exists then | if mw.title.new(mus).exists then | ||
break | break | ||
| Zeile 66: | Zeile 66: | ||
t=t..mus | t=t..mus | ||
else | else | ||
t=t..':Kategorie:'.. | t=t..':Kategorie:'..kal.month_names[mu] | ||
end | end | ||
t=t..'|►]]</th>' | t=t..'|►]]</th>' | ||
-- A weng | -- A weng ungampert, aber funktioniert ;-) | ||
t=t.. | 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> | t=t..'</table>' | ||
return t | return t | ||
end | end | ||
function | function p.woche(day, month) | ||
a=6 | local a = 6 | ||
if | if day == 29 then | ||
if contains({'April', 'Juni', 'September', 'November'}, month) then | if arr.contains({'April', 'Juni', 'September', 'November'}, month) then | ||
a=1 | a=1 | ||
elseif month == 'Februar' then | elseif month == 'Februar' then | ||
| Zeile 93: | Zeile 92: | ||
end | end | ||
t = '<tr>' | local t = '<tr>' | ||
for i= | for i=day, day + a do | ||
t=t..'<td align="right">[['..i..'. '..month..'|'..i..']]</td>' | t = t .. '<td align="right">[['..i..'. ' .. month .. '|' .. i .. ']]</td>' | ||
end | end | ||
t = t..'</tr>' | t = t..'</tr>' | ||
return t | return t | ||
end | end | ||
return p | return p | ||
Aktuelle Version vom 28. Dezember 2025, 19:10 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 com = require("Modul:Common")
local str = require("Modul:String")
local arr = require("Modul:Array")
local kal = require("Modul:Kalender")
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 com.len(ma) == 1 then
day = 0
month = ma[1]
else
day = str.rstrip(ma[1])
month = str.lstrip(ma[2])
end
month_nr = kal.month_numbers[month]
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..'. '..kal.month_names[md]
for i = 0, 2 do
mds = tostring(day-i)..'. '..kal.month_names[md]
if mw.title.new(mds).exists then
break
end
end
t=t..mds
else
t=t..':Kategorie:'..kal.month_names[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..'. '..kal.month_names[mu]
for i = 0, 2 do
mus = tostring(day-i)..'. '..kal.month_names[mu]
if mw.title.new(mus).exists then
break
end
end
t=t..mus
else
t=t..':Kategorie:'..kal.month_names[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