Modul:Chronik: Unterschied zwischen den Versionen

Aus FürthWiki

Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 17: Zeile 17:
-- Wenn das Lemma eine Jahreszahl ist, merken
-- Wenn das Lemma eine Jahreszahl ist, merken
if c.istJahreszahl(frame) == "true" then
if istJahreszahl(frame) then
year = titlename
year = titlename
     end
     end

Version vom 22. August 2025, 17:24 Uhr

local p = {}
local c = require("Modul:Common")
local lf = require("Modul:LinkFormDatum")
local ls = 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(frame) 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
	local d=split(s, '-')
	local sd=human_to_form_date(d[0])
	
	local data = {
		-- Erstmal das Startdatum schreiben
		["Startdatum"] = sd,
		["Startjahr"] = get_year(sd),
		["Starttag"] = get_monthday(sd),
		["length"] = len(d),
		["year"] = year,
		['dusche'] = year .. 'DUSCH!',
	}
	
	local ed=nil
	if len(d) == 2 then
		-- War eine Zeitspanne angegeben gibt es ein Endatum
		ed=human_to_form_date(d[1])
		data["Enddatum"] = ed
		data["Endjahr"] = get_year(ed)
		data["Endtag"] = get_monthday(ed)
	end
	return data
end

return p