Modul:Jahrestag: Unterschied zwischen den Versionen

K
Entfernte den Schutz von „Modul:Jahrestag
K (Red Rooster verschob die Seite Modul:Monatstag nach Modul:Jahrestag, ohne dabei eine Weiterleitung anzulegen: Textersetzung - „Monatstag“ durch „Jahrestag“)
K (Entfernte den Schutz von „Modul:Jahrestag“)
 
(15 dazwischenliegende Versionen von 2 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, '.')
ma=split(pt, '.')
local day, month, month_nr
if #ma == 0 then
local md, mu -- month down/month up
if c.len(ma) == 1 then
day = 0
day = 0
month = ma[0]
month = ma[1]
else
else
day = rtrim(ma[0])
day = str.rstrip(ma[1])
month = ltrim(ma[1])
month = str.lstrip(ma[2])
end
end
months=getMonthList()
local months=c.getMonthList()
for i, v in ipairs(months) do
for i, v in ipairs(months) do
if v == month then
if v == month then
Zeile 22: Zeile 25:
end
end


t='<table class="wikitable monatsbox">'..
local t='<table class="wikitable monatsbox">'..
  '<tr>'
'<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
end
end
-- Der md (month-down-button) verlinkt zum nächsten Tag der existiert
     t=t..'<th>[['
     t=t..'<th>[['
     if day ~= 0 then
     if day ~= 0 then
     t=t..day..'. '..months[md]
     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
     else
     t=t..':Kategorie:'..months[md]
     t=t..':Kategorie:'..months[md]
Zeile 40: Zeile 52:
      
      
     -- 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
end
end
-- Der mu (month-up-button) verlinkt zum nächsten Tag der existiert
     t=t..'<th>[['
     t=t..'<th>[['
     if day ~= 0 then
     if day ~= 0 then
     t=t..day..'. '..months[mu]
     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
else
     t=t..':Kategorie:'..months[mu]
     t=t..':Kategorie:'..months[mu]
Zeile 52: Zeile 73:
     t=t..'|►]]</th>'
     t=t..'|►]]</th>'
-- A weng ungambert, aber funktioniert ;-)
-- A weng ungampert, aber funktioniert ;-)
t=t..Woche(1, month)..
t=t..p.woche(1, month) ..
Woche(8, month)..
p.woche(8, month) ..
Woche(15, month)..
p.woche(15, month) ..
Woche(22, month)..
p.woche(22, month) ..
Woche(29, month)
p.woche(29, month)
t=t..'</table>'..
t=t..'</table>'
'[[Kategorie:'..month..']]'
return t
return t
end  
end  


function Woche(d, month)
function p.woche(day, month)
a=6
local a = 6
if d == 29 then
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 75: Zeile 95:
end
end
t = '<tr>'
local t = '<tr>'
for i=d, d+a do
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