Modul:Chronik: Unterschied zwischen den Versionen

Namenskonvention für Modul-Importe
Keine Bearbeitungszusammenfassung
(Namenskonvention für Modul-Importe)
Zeile 1: Zeile 1:
local p = {}
local p = {}
local str = require("Modul:String")
local str = require("Modul:String")
local sr = require("Modul:Subrefs")
local srf = require("Modul:Subrefs")
local c = require("Modul:Common")
local com = require("Modul:Common")
local lfd = require("Modul:LinkFormDatum")
local lfd = require("Modul:LinkFormDatum")
local lsd = require("Modul:LinkSubformDatum")
local lsd = require("Modul:LinkSubformDatum")
Zeile 13: Zeile 13:
local thema = frame.args["Thema"] or "Ereignis"
local thema = frame.args["Thema"] or "Ereignis"
local year = nil
local year = nil
if c.istJahreszahl(title) then
if com.istJahreszahl(title) then
year = title
year = title
end
end
local data = p.dateParser(daterange, year)
local data = p.dateParser(daterange, year)
local ds = ''
local ds = ''
if not c.isEmpty(data['Starttag']) then
if not com.isEmpty(data['Starttag']) then
ds = '[[' .. data['Starttag'] .. ']]'
ds = '[[' .. data['Starttag'] .. ']]'
end
end
Zeile 37: Zeile 37:
local t
local t
if option == "nodate" then
if option == "nodate" then
t = sr.subrefs(text)
t = srf.subrefs(text)
else
else
t = ds .. ': ' .. sr.subrefs(text)
t = ds .. ': ' .. srf.subrefs(text)
end
end
return frame:preprocess(t)
return frame:preprocess(t)
Zeile 72: Zeile 72:
local sd = str.split(start_date, ' ')
local sd = str.split(start_date, ' ')
if not c.isEmpty(end_date) then
if not com.isEmpty(end_date) then
-- Wenn ein Enddatum gegeben ist
-- Wenn ein Enddatum gegeben ist
local ed = str.split(end_date, ' ')
local ed = str.split(end_date, ' ')
mw.logObject(ed)
mw.logObject(ed)
if c.len(ed) == 2 then
if com.len(ed) == 2 then
-- Wenn das Enddatum kein Jahr enthält, füge es aus year hinzu
-- Wenn das Enddatum kein Jahr enthält, füge es aus year hinzu
ed[3] = year
ed[3] = year
end_date = end_date .. " " .. ed[3]
end_date = end_date .. " " .. ed[3]
end
end
if c.len(sd) == 2 then
if com.len(sd) == 2 then
-- Wenn das Startdatum kein Jahr enthält, hole es von Enddatum
-- Wenn das Startdatum kein Jahr enthält, hole es von Enddatum
start_date = start_date .. " " .. ed[3]
start_date = start_date .. " " .. ed[3]
elseif c.len(sd) == 1 then
elseif com.len(sd) == 1 then
-- Startdatum enthält weder Monat noch Jahr, hole sie von Enddatum
-- Startdatum enthält weder Monat noch Jahr, hole sie von Enddatum
start_date = start_date .. " " .. ed[2] .. " " .. ed[3]
start_date = start_date .. " " .. ed[2] .. " " .. ed[3]
Zeile 93: Zeile 93:
return start_date, end_date
return start_date, end_date
end
end
if c.len(sd) == 2 then
if com.len(sd) == 2 then
-- Wenn das Startdatum kein Jahr enthält, hole es aus year
-- Wenn das Startdatum kein Jahr enthält, hole es aus year
sd[3] = year
sd[3] = year
start_date = start_date .. " " .. sd[3]
start_date = start_date .. " " .. sd[3]
elseif c.len(sd) == 1 then
elseif com.len(sd) == 1 then
sd[3] = year
sd[3] = year
start_date = start_date .. " " .. sd[3]
start_date = start_date .. " " .. sd[3]
Zeile 109: Zeile 109:
local dates = str.split(s, "-")
local dates = str.split(s, "-")
-- Wenn splitten mit "-" nur ein Ergebnis bringt, splitte mit "bis"
-- Wenn splitten mit "-" nur ein Ergebnis bringt, splitte mit "bis"
if c.len(dates) == 1 then
if com.len(dates) == 1 then
dates = str.split(s, "bis")
dates = str.split(s, "bis")
end
end