Dieses Modul befasst sich mit Datumskonversionen bei Subformularen, wenn also Subobjekte abgebildet werden sollen. Es geht um die Konvertierung der Datumsformate, wie sie auch bei normalen Formularen stattfinden.

GetMonthday

Konvertiert ein Formular-Datum wie 2025/01/08 zu 8. Januar. Ist das Format Oktober 2022 kommt Oktober raus.

GetYear

Konvertiert ein Formular-Datum wie 2025/01/08 zu 2025. Es versteht aber auch das Datumsformat Oktober 2022



local p = {}
local c = require( "Module:Common" )
local str = require("Modul:String")

function p.GetMonthday(frame)
	pf = frame:getParent()
	args = pf.args
	date = args[1]
	return get_monthday(date)
end

function get_monthday(date)
	months=getMonthList()
	date_array=str.split(date, "/")
	if isEmpty(date_array[1]) then
		-- When datestring contained no "/"
		mda = str.split(date_array[0])
		if isEmpty(mda[1]) then
			-- When dateformat is just YYYY
			return ""
		else
			-- Dateformat is <monthname> YYYY
			return mda[0]
		end
	else
		mn = months[tonumber(date_array[1])]
		date_array[2] = date_array[2]:gsub('0*', '', 1)
		return date_array[2]:gsub("%s+", "") .. ". " .. mn
	end
end

function p.GetYear(frame)
	args = frame.args
	date = args[1]
	return get_year(date)
end

function get_year(date)
	date_array=str.split(date, "/")
	if isEmpty(date_array[1]) then
		-- When datestring contained no "/"
		mda = str.split(date_array[0])
		if isEmpty(mda[1]) then
			-- When dateformat is just YYYY
			return mda[0]
		else
			-- Dateformat is <monthname> YYYY
			return mda[1]
		end
	elseif isEmpty(date_array[2]) then
		-- Datestring contained one "/"
		return date_array[0]
	else
		-- Dateformat should be YYYY/MM/DD
		return date_array[0]
	end
end

return p