Modul:Chronik: Unterschied zwischen den Versionen
Aus FürthWiki
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 30: | Zeile 30: | ||
-- Wenn s eine Zeitspanne ist, teile bei "-" oder "bis" | -- Wenn s eine Zeitspanne ist, teile bei "-" oder "bis" | ||
local dates=split(s, '-') | local dates=split(s, '-') | ||
if len( | if len(dates) == 1 then | ||
dates=split(s, 'bis') | dates=split(s, 'bis') | ||
end | end | ||
| Zeile 36: | Zeile 36: | ||
-- Ist eine Zeitspanne wie "3. bis 5. Mai" angegeben, kopiere Monat aus Enddatum | -- Ist eine Zeitspanne wie "3. bis 5. Mai" angegeben, kopiere Monat aus Enddatum | ||
local sds = checkYear(dates[0], year) | local sds = checkYear(dates[0], year) | ||
local sd=human_to_form_date( | local sd=human_to_form_date(dates[0]) | ||
| Zeile 45: | Zeile 45: | ||
["Startjahr"] = get_year(sd), | ["Startjahr"] = get_year(sd), | ||
["Starttag"] = get_monthday(sd), | ["Starttag"] = get_monthday(sd), | ||
["length"] = len( | ["length"] = len(dates), | ||
["year"] = year, | ["year"] = year, | ||
} | } | ||
| Zeile 52: | Zeile 52: | ||
if len(dates) == 2 then | if len(dates) == 2 then | ||
-- War eine Zeitspanne angegeben gibt es ein Endatum | -- War eine Zeitspanne angegeben gibt es ein Endatum | ||
ed=human_to_form_date( | ed=human_to_form_date(dates[1]) | ||
data["EDstring"] = | data["EDstring"] = dates[1] | ||
data["Enddatum"] = ed | data["Enddatum"] = ed | ||
data["Endjahr"] = get_year(ed) | data["Endjahr"] = get_year(ed) | ||
Version vom 22. August 2025, 19:22 Uhr
local p = {}
local c = require("Modul:Common")
local lfd = require("Modul:LinkFormDatum")
local lsd = require("Modul:LinkSubformDatum")
function p.Eintrag(frame)
local args = frame.args
local title = mw.title.getCurrentTitle()
local titlename = title.text
local fulltitle = title.fullText
local year
local data = {
["Beschreibung"] = args[2],
["Thema"] = "Ereignis",
["Artikel"] = fulltitle
}
-- Wenn das Lemma eine Jahreszahl ist, merken
if istJahreszahl(titlename) then
year = titlename
end
local data_date = dateParsing(args[1], year)
local all_data = merge_tables(data, data_date)
return data_date["Startdatum"] .. ": " .. args[2] .. '<br>' ..
tableToString(all_data)
end
function dateParsing(s, year)
-- Parses a date down where s is the datestring and year can be nil or string
-- Wenn s eine Zeitspanne ist, teile bei "-" oder "bis"
local dates=split(s, '-')
if len(dates) == 1 then
dates=split(s, 'bis')
end
-- Ist eine Zeitspanne wie "3. bis 5. Mai" angegeben, kopiere Monat aus Enddatum
local sds = checkYear(dates[0], year)
local sd=human_to_form_date(dates[0])
local data = {
-- Erstmal das Startdatum schreiben
["SDstring"] = dates[0],
["Startdatum"] = sd,
["Startjahr"] = get_year(sd),
["Starttag"] = get_monthday(sd),
["length"] = len(dates),
["year"] = year,
}
local ed=nil
if len(dates) == 2 then
-- War eine Zeitspanne angegeben gibt es ein Endatum
ed=human_to_form_date(dates[1])
data["EDstring"] = dates[1]
data["Enddatum"] = ed
data["Endjahr"] = get_year(ed)
data["Endtag"] = get_monthday(ed)
end
return data
end
function checkYear(s, year)
-- Wenn s nicht auf eine Jahreszahl endet, dann füge diese hinzu
return s
end
function checkMonth(s, month)
-- Aua
return s
end
return p