82.367
Bearbeitungen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 16: | Zeile 16: | ||
local args = frame.args | local args = frame.args | ||
local title = mw.title.getCurrentTitle().text | local title = mw.title.getCurrentTitle().text | ||
local tag, monat = | local tag, monat = p.ist_jahrestag(title) | ||
if tag and monat then | if tag and monat then | ||
| Zeile 25: | Zeile 25: | ||
end | end | ||
function | function p.ist_jahrestag(s) | ||
s = s or "" | s = s or "" | ||
-- Prüfe auf ein-/zweistellige Zahl durch Punkt gefolgt, opt. Leerzeichen | -- Prüfe auf ein-/zweistellige Zahl durch Punkt gefolgt, opt. Leerzeichen | ||
| Zeile 35: | Zeile 35: | ||
local title = mw.title.getCurrentTitle().text | local title = mw.title.getCurrentTitle().text | ||
if | if p.ist_jahreszahl(title) then | ||
return args[1] or "true" | return args[1] or "true" | ||
else | else | ||
| Zeile 42: | Zeile 42: | ||
end | end | ||
function | function p.ist_jahreszahl(s) | ||
s = s or "" | s = s or "" | ||
-- Prüfe auf Formate wie: 2024, -44, 44 v. Chr., 800 n. Chr. | -- Prüfe auf Formate wie: 2024, -44, 44 v. Chr., 800 n. Chr. | ||
| Zeile 60: | Zeile 60: | ||
end | end | ||
function getMonthList() | function p.getMonthList() | ||
-- Returns a numbered List of all monthnames | -- Returns a numbered List of all monthnames | ||
return { | return { | ||
| Zeile 77: | Zeile 77: | ||
end | end | ||
function getMonthnr(name) | function p.getMonthnr(name) | ||
-- Returns the number of the given monthname | -- Returns the number of the given monthname | ||
local months = getMonthList() | local months = getMonthList() | ||
| Zeile 91: | Zeile 91: | ||
end | end | ||
function len(t) | function p.len(t) | ||
-- Überprüfe, ob es ein String ist | -- Überprüfe, ob es ein String ist | ||
if type(t) == "string" then | if type(t) == "string" then | ||
| Zeile 110: | Zeile 110: | ||
return nil -- Falls der Typ nicht unterstützt wird | return nil -- Falls der Typ nicht unterstützt wird | ||
end | end | ||
end | end | ||
| Zeile 126: | Zeile 116: | ||
end | end | ||
function get_key_for_value( t, value ) | function p.get_key_for_value( t, value ) | ||
for k, v in pairs(t) do | for k, v in pairs(t) do | ||
if v==value then return k end | if v==value then return k end | ||
| Zeile 133: | Zeile 123: | ||
end | end | ||
function | function p.merge_arrays(t1, t2) | ||
-- merge tables that are arrays: {1,2,3} and {3,4,5} | -- merge tables that are arrays: {1,2,3} and {3,4,5} | ||
local result = {} | local result = {} | ||
| Zeile 163: | Zeile 135: | ||
end | end | ||
function merge_tables(t1, t2) | function p.merge_tables(t1, t2) | ||
-- merge tables that are key-value: {a=1, b=2} and {c=3, d=4} | -- merge tables that are key-value: {a=1, b=2} and {c=3, d=4} | ||
local result={} | local result={} | ||
| Zeile 173: | Zeile 145: | ||
end | end | ||
return result | return result | ||
end | end | ||
| Zeile 196: | Zeile 156: | ||
end | end | ||
function tableToString(tbl, indent) | function p.tableToString(tbl, indent) | ||
-- Prints a LUA-Table as string. Very useful if you want to see whats inside | -- Prints a LUA-Table as string. Very useful if you want to see whats inside | ||
indent = indent or 0 | indent = indent or 0 | ||