15.075
Bearbeitungen
K (Entfernte den Schutz von „Modul:LinkFormDatum“) |
(linkFormDate auch ohne Attribute) |
||
| Zeile 15: | Zeile 15: | ||
local mn -- monthname | local mn -- monthname | ||
mw.smw.set({[attr_date] = date}) | -- wenn keine Attribute übergeben, werden keine gesetzt, sondern nur Links eingebaut | ||
if attr_day ~= nil then | |||
attr_day = attr_day .. "::" | |||
else | |||
attr_day = "" | |||
end | |||
if attr_year ~= nil then | |||
attr_year = attr_year .. "::" | |||
else | |||
attr_year = "" | |||
end | |||
if attr_date ~= nil then | |||
mw.smw.set({[attr_date] = date}) | |||
end | |||
if c.isEmpty(date_array[2]) then | if c.isEmpty(date_array[2]) then | ||
-- When datestring contained no "/" | -- When datestring contained no "/" | ||
if c.isInteger(date_array[1]) then | if c.isInteger(date_array[1]) then | ||
-- When dateformat is just YYYY | -- When dateformat is just YYYY | ||
return "[[" .. attr_year | return "[[" .. attr_year .. date_array[1] .. "]]" | ||
else | else | ||
-- Dateformat is <monthname> YYYY | -- Dateformat is <monthname> YYYY | ||
mda = str.split(date_array[1]) | mda = str.split(date_array[1]) | ||
return mda[1] .. " [[" .. attr_year | return mda[1] .. " [[" .. attr_year .. mda[2] .. "]]" | ||
end | end | ||
elseif c.isEmpty(date_array[3]) then | elseif c.isEmpty(date_array[3]) then | ||
-- Datestring contained one "/" | -- Datestring contained one "/" | ||
mn = months[tonumber(date_array[2])] | mn = months[tonumber(date_array[2])] | ||
return mn .. " [[" .. attr_year | return mn .. " [[" .. attr_year .. date_array[1] .. "]]" | ||
else | else | ||
-- Dateformat should be YYYY/MM/DD | -- Dateformat should be YYYY/MM/DD | ||
mn = months[tonumber(date_array[2])] | mn = months[tonumber(date_array[2])] | ||
date_array[3] = date_array[3]:gsub('0*', '', 1) | date_array[3] = date_array[3]:gsub('0*', '', 1) | ||
return "[[" .. attr_day | return "[[" .. attr_day .. date_array[3] .. ". " .. mn .. "]]" .. | ||
" [[" .. attr_year | " [[" .. attr_year .. date_array[1] .. "]]" | ||
end | end | ||
end | end | ||