15.207
Bearbeitungen
(Variablen Schreibweise) |
(+ subobjectIdCleaner()) |
||
| (7 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
local p = {} | local p = {} | ||
local com = require("Modul:Common") | local com = require("Modul:Common") | ||
local str = require("Modul:String") | local str = require("Modul:String") | ||
| Zeile 70: | Zeile 71: | ||
local filter = "" | local filter = "" | ||
suchtext = str.strip(tostring(suchtext or "")) | suchtext = str.strip(tostring(suchtext or "")) | ||
if suchtext == "" then | if suchtext == "" or suchtext == "*" then | ||
filter = "+" | filter = "+" | ||
else | else | ||
| Zeile 84: | Zeile 85: | ||
ft = str.strip(ft) | ft = str.strip(ft) | ||
if ft ~= "" then | if ft ~= "" then | ||
filter = filter .. "||~*" .. ft .. "*" | filter = filter .. "||~*" .. ft .. "*" .. "||" .. ft | ||
end | end | ||
end | end | ||
| Zeile 92: | Zeile 93: | ||
-- mw.log(filter) | -- mw.log(filter) | ||
return filter | return filter | ||
end | |||
function p.dateLastDayCompleter(date) | |||
local last_date | |||
if #date == 4 then -- nur "Jahr" vorhanden | |||
last_date = date .. "/12/31" | |||
elseif #date ~= 10 then -- "Monat Jahr" vorhanden | |||
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 = com.getMonthnr(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 | |||
else | |||
last_date = date | |||
end | |||
return last_date | |||
end | |||
function p.subobjectIdCleaner(id) | |||
local id_clean = "" | |||
for i = 1, mw.ustring.len(id) do | |||
local char = mw.ustring.sub(id, i, i) | |||
if char == "." then | |||
id_clean = id_clean .. "_" | |||
else | |||
id_clean = id_clean .. char | |||
end | |||
end | |||
return id_clean | |||
end | end | ||
return p | return p | ||