Modul:Chronik: Unterschied zwischen den Versionen

Aus FürthWiki

Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 37: Zeile 37:
-- 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 = p.checkYear(dates[1], year)
local sds = p.checkYear(dates[1], year)
local sd = lfd.human_to_form_date(dates[1])
local sd = lfd.humanToFormDate(dates[1])
local data = {
local data = {
Zeile 52: Zeile 52:
if c.len(dates) >= 2 then
if c.len(dates) >= 2 then
-- War eine Zeitspanne angegeben gibt es ein Endatum
-- War eine Zeitspanne angegeben gibt es ein Endatum
ed=lfd.human_to_form_date(dates[2])
ed=lfd.humanToFormDate(dates[2])
data["EDstring"] = dates[2]
data["EDstring"] = dates[2]
data["Enddatum"] = ed
data["Enddatum"] = ed

Version vom 27. August 2025, 08:38 Uhr

local p = {}
local c = require("Modul:Common")
local str = require("Modul:String")
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 c.istJahreszahl(titlename) then
		year = titlename
    end
    local data_date = p.dateParsing(args[1], year)
    local all_data = c.merge_tables(data, data_date)
	return data_date["Startdatum"] .. ": " .. args[2] --.. '<br>' ..
		--tableToString(all_data)
end

function p.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 = str.split(s, 'bis') -- split hatte in Modul:Commons einen bug(!)
	if c.len(dates) == 1 then
		dates=str.split(s, 'bis')
	end
	
	-- Ist eine Zeitspanne wie "3. bis 5. Mai" angegeben, kopiere Monat aus Enddatum 
	local sds = p.checkYear(dates[1], year)
	local sd = lfd.humanToFormDate(dates[1])
	
	local data = {
		-- Erstmal das Startdatum schreiben
		["SDstring"] = dates[1],
		["Startdatum"] = sd,
		["Startjahr"] = lsd.get_year(sd),
		["Starttag"] = lsd.get_monthday(sd),
		["length"] = c.len(dates),
		["year"] = year,
	}
	
	local ed
	if c.len(dates) >= 2 then
		-- War eine Zeitspanne angegeben gibt es ein Endatum
		ed=lfd.humanToFormDate(dates[2])
		data["EDstring"] = dates[2]
		data["Enddatum"] = ed
		data["Endjahr"] = lsd.get_year(ed)
		data["Endtag"] = lsd.get_monthday(ed)
	end
	if c.len(dates) >= 3 then
		data["3 is"] = dates[3]
	end
	return data
end

function p.checkYear(s, year)
	-- Wenn s nicht auf eine Jahreszahl endet, dann füge diese hinzu
    return s
end

function p.checkMonth(s, month)
	-- Aua
	return s
end

return p