Modul:Kalender: Unterschied zwischen den Versionen

- getMonthList() obsolete, -getMonthnr() obsolete, +/fix dateLastDayCompleter() von Modul:SMW
(+ month_names, month_numbers)
(- getMonthList() obsolete, -getMonthnr() obsolete, +/fix dateLastDayCompleter() von Modul:SMW)
Zeile 47: Zeile 47:
end
end


function p.getMonthList()
function p.dateLastDayCompleter(date)
-- Returns a numbered List of all monthnames
-- ergänzt letzten Tag für SMW-Query
return {
-- 2000 => 2000/12/31
[1] = "Januar",
-- Februar 2000 => 2000/2/29
[2] = "Februar",
-- Februar 2001 => 2001/2/28
[3] = "März",
-- 2020/04/02 => 2020/04/02
[4] = "April",
local last_date
[5] = "Mai",
if #date == 4 then -- nur "Jahr" vorhanden
[6] = "Juni",
last_date = date .. "/12/31"
[7] = "Juli",
elseif string.find(date, " ") ~= nil then -- "Monat Jahr" vorhanden (hat Leerzeichen)
[8] = "August",
local days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
[9] = "September",
local month = string.sub(date, 1, string.find(date, " ") - 1)
[10] = "Oktober",
month = p.month_numbers[month]
[11] = "November",
local year = string.sub(date, string.find(date, " ") + 1)
[12] = "Dezember"}
last_date = year .. "/" .. month .. "/"
end
if month == 2 and year % 4 == 0 then -- Sonderfall Feb. Schaltjahr
 
last_date = last_date .. "29"
function p.getMonthnr(name)
else
-- Returns the number of the given monthname
last_date = last_date .. days[month]
local months = p.getMonthList()
for nr, mn in pairs(months) do
if mn == name then
return nr
end
end
else
last_date = date
end
end
return last_date
end
end