Modul:Vorlage:ISO-Datum
Erscheinungsbild
Modul:Vorlage:LuaModuleDoc:144: attempt to index field 'wikibase' (a nil value)
Diese Vorlage dient der Konvertierung eines ausgeschriebenen Datums in das ISO-Format.
<templatestyles src="TOC nonum/styles.css"></templatestyles>
⧼templatedata-doc-params⧽
| ⧼templatedata-doc-param-name⧽ | ⧼templatedata-doc-param-desc⧽ | ⧼templatedata-doc-param-type⧽ | ⧼templatedata-doc-param-status⧽ | |
|---|---|---|---|---|
| Datum | Datum1 | Die Zeichenkette, welche das Datum darstellt. Die Vorlage funktioniert mit jeder Zeichenkette, welche mit „1.“ bis „31.“ anfängt, mit „ 100“ bis „9999“ endet und irgendwo dazwischen einen ausgeschriebenen Monatsnamen enthält. Ein Test auf Gültigkeit des Datums erfolgt nicht.
| ⧼templatedata-doc-param-type-date⧽ | ⧼templatedata-doc-param-status-required⧽ |
Kopiervorlage
<syntaxhighlight lang="wikitext" copy> 0000-00-00 </syntaxhighlight>
Beispiele
<syntaxhighlight lang="wikitext"> 1990-10-03 </syntaxhighlight> ergibt: 1990-10-03
<syntaxhighlight lang="wikitext"> 1990-02-30 </syntaxhighlight> ergibt: 1990-02-30
Lua
Verwendetes Modul: Vorlage:ISO-Datum
local ISO = {}
function exec(data)
local isOk = false;
local a = 0;
local b = 0;
local text = tostring(data);
local day = "";
local month = "";
local year ="";
local s = ""
local txty = "";
local txtd = "";
txty = string.sub(text,-4);
a = tonumber(txty) or 0;
year=string.format("%4.4d",a);
if string.find(text,"Januar") then month="-01";
elseif string.find(text,"Jänner") then month="-01";
elseif string.find(text,"Februar") then month="-02";
elseif string.find(text,"März") then month="-03";
elseif string.find(text,"April") then month="-04";
elseif string.find(text,"Mai") then month="-05";
elseif string.find(text,"Juni") then month="-06";
elseif string.find(text,"Juli") then month="-07";
elseif string.find(text,"August") then month="-08";
elseif string.find(text,"September") then month="-09";
elseif string.find(text,"Oktober") then month="-10";
elseif string.find(text,"November") then month="-11";
elseif string.find(text,"Dezember") then month="-12";
else month="-00";
end
txtd = string.sub(text,1,2);
for idx = 1,9 do
s = string.format("%s.",idx)
if s == txtd then
day = string.format("-%2.2d",idx);
break;
end
end
if day =="" then
txtd = string.sub(text,1,3);
for idx = 10,31 do
s = string.format("%s.",idx)
if s == txtd then
day = string.format("-%2.2d",idx);
break;
end
end
end
if day =="" then day = "-00"; end;
s = year .. month .. day;
return s;
end
function ISO.Run(frame)
return exec(frame.args[1])
end
return ISO