26.714
Bearbeitungen
(+ month_names, month_numbers) |
(- getMonthList() obsolete, -getMonthnr() obsolete, +/fix dateLastDayCompleter() von Modul:SMW) |
||
| Zeile 47: | Zeile 47: | ||
end | end | ||
function p. | function p.dateLastDayCompleter(date) | ||
-- | -- ergänzt letzten Tag für SMW-Query | ||
-- 2000 => 2000/12/31 | |||
-- Februar 2000 => 2000/2/29 | |||
-- Februar 2001 => 2001/2/28 | |||
-- 2020/04/02 => 2020/04/02 | |||
local last_date | |||
if #date == 4 then -- nur "Jahr" vorhanden | |||
last_date = date .. "/12/31" | |||
elseif string.find(date, " ") ~= nil then -- "Monat Jahr" vorhanden (hat Leerzeichen) | |||
[ | local days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} | ||
local month = string.sub(date, 1, string.find(date, " ") - 1) | |||
month = p.month_numbers[month] | |||
local year = string.sub(date, string.find(date, " ") + 1) | |||
last_date = year .. "/" .. month .. "/" | |||
if month == 2 and year % 4 == 0 then -- Sonderfall Feb. Schaltjahr | |||
last_date = last_date .. "29" | |||
else | |||
last_date = last_date .. days[month] | |||
end | end | ||
else | |||
last_date = date | |||
end | end | ||
return last_date | |||
end | end | ||