20.472
Bearbeitungen
(- Kategorie:Fehlerhafte Adresse) |
(fix formDate2CompareIndex()) |
||
| Zeile 67: | Zeile 67: | ||
-- subobject setzen | -- subobject setzen | ||
mw.smw.subobject(attr, subobject) | mw.smw.subobject(attr, subobject) | ||
-- Plausibilitätsprüfung von/bis | -- Plausibilitätsprüfung von/bis | ||
if attr["AdresseVon"] ~= nil and attr["AdresseBis"] ~= nil and | if attr["AdresseVon"] ~= nil and attr["AdresseBis"] ~= nil and | ||
p. | p.formDate2CompareIndex(attr["AdresseVon"], "von") > p.formDate2CompareIndex(attr["AdresseBis"], "bis") then | ||
fail = true | fail = true | ||
end | end | ||
| Zeile 86: | Zeile 86: | ||
end | end | ||
function p. | function p.formDate2CompareIndex(date, vonbis) | ||
-- mw.log(" | -- mw.log("formDate2CompareIndex(" .. date .. ")") | ||
-- Datum in Index wandeln | -- Datum in Index wandeln | ||
-- Bsp.: 23 April 1989 => 19890423 | -- Bsp.: 23 April 1989 => 19890423 | ||
-- Konsolenzeile zum Debuggen: | -- Konsolenzeile zum Debuggen: | ||
-- =p. | -- =p.formDate2CompareIndex("2000","von") | ||
-- =p. | -- =p.formDate2CompareIndex("2000","bis") | ||
-- =p. | -- =p.formDate2CompareIndex("Februar 2000","von") | ||
-- =p. | -- =p.formDate2CompareIndex("Februar 2000","bis") | ||
-- =p. | -- =p.formDate2CompareIndex("2000/02/03","von") | ||
-- =p. | -- =p.formDate2CompareIndex("2000/02/03","bis") | ||
local index = "" | local index = "" | ||
local date=str.split2(date, " ") | local date = str.split2(date, "/") | ||
if #date == 1 then | if #date == 3 then -- komplettes Datum vorhanden | ||
index = tostring(date[1]) .. tostring(date[2]) .. tostring(date[3]) | |||
else | |||
date = str.split2(date[1], " ") | |||
if #date == 1 then -- nur Jahr vorhanden | |||
index = tostring(date[1]) | |||
if vonbis == "von" then | |||
index = index .. "0101" | |||
else | |||
index = index .. "1231" | |||
end | |||
elseif #date == 2 then -- nur Monat + Jahr vorhanden | |||
index = tostring(date[2]) .. string.format("%02d", kal.month_numbers[date[1]]) | |||
if vonbis == "von" then | |||
index = index .. "01" | |||
else | |||
index = index .. "31" | |||
end | |||
end | end | ||
end | end | ||
index = tonumber(index) or 0 | index = tonumber(index) or 0 | ||