26.714
Bearbeitungen
(+ dateFirstDayCompleter(), date2ISO()) |
(p.date2ISO() Optimierungen) |
||
| Zeile 93: | Zeile 93: | ||
function p.date2ISO(date) | function p.date2ISO(date) | ||
-- 2000 => 2000 | -- 2000 => 2000 | ||
-- Februar 2000 => 2000-02 | -- Februar 2000 => 2000-02 | ||
-- 2020/04/02 => 2020-04-02 | -- 2020/04/02 => 2020-04-02 | ||
local date_iso = "" | local date_iso = "" | ||
date = p. | if #date == 4 then -- nur "Jahr" vorhanden | ||
for i = 1, #date do | date_iso = date | ||
elseif string.find(date, " ") ~= nil then -- "Monat Jahr" vorhanden (hat Leerzeichen) | |||
local month = string.sub(date, 1, string.find(date, " ") - 1) | |||
month = p.month_numbers[month] | |||
date_iso = string.sub(date, string.find(date, " ") + 1) | |||
if month ~= nil then | |||
date_iso = date_iso .. "-" .. string.format("%02d", month) | |||
end | |||
else | |||
for i = 1, #date do | |||
local char = string.sub(date, i, i) | |||
if char == "/" then | |||
date_iso = date_iso .. "-" | |||
else | |||
date_iso = date_iso .. char | |||
end | |||
end | end | ||
end | end | ||