Modul:DateLb
Ausgesinn
local fun = {}
function fun.formatDate(dateToFormat)
local num = 0
local dateToLink = dateToFormat.args[1]
local result = ""
local a = {}
for i in string.gmatch(dateToLink, "%S+") do
a[num] = i
num = num + 1
end
---- num == 5 ----
-- Dag Mount Joer v. Chr. (julianesch)
if num == 5 and
string.match(dateToLink, "^[%d]+%. [%D]+ [%d]+ v%. Chr%. %(julianesch%)$") ~= nil then
result = "[["..a[0].." "..a[1].."]] [["..a[2].." "..a[3].."]] <sup>[[Julianesche Kalenner|jul.]]</sup>"
---- num == 4 ----
elseif num == 4 then
if -- Dag Mount Joer v. Chr.
string.match(dateToLink, "^[%d]+%. [%D]+ [%d]+ v%. Chr%.$") ~= nil then
result = "[["..a[0].." "..a[1].."]] [["..a[2].." "..a[3].."]]"
elseif -- Dag Mount Joer (julianesch)
string.match(dateToLink, "^[%d]+%. [%D]+ [%d]+ %(julianesch%)$") ~= nil then
result = "[["..a[0].." "..a[1].."]] [["..a[2].."]] <sup>[[Julianesche Kalenner|jul.]]</sup>"
elseif -- Mount Joer v. Chr. (julianesch)
string.match(dateToLink, "^[%D]+ [%d]+ v%. Chr%. %(julianesch%)$") ~= nil then
result = "[["..a[0].."]] [["..a[1].." "..a[2].."]] <sup>[[Julianesche Kalenner|jul.]]</sup>"
elseif -- n. Joerdausend/Joerhonnert v. Chr. (julianesch)
string.match(dateToLink, "^[%d]+%. Joer[dh][ao][un][sn]e[nr][dt] v%. Chr%. %(julianesch%)$") ~= nil then
result = "[["..a[0].." "..a[1].." "..a[2].."]] <sup>[[Julianesche Kalenner|jul.]]</sup>"
else
result = dateToLink.."[[Kategorie:Brasilianesch Foussballspiller]]"
end
---- num == 3 ----
elseif num == 3 then
if -- Dag Mount Joer
string.match(dateToLink, "^[%d]+%. [%D]+ [%d]+$") ~= nil then
result = "[["..a[0].." "..a[1].."]] [["..a[2].."]]"
elseif -- Mount Joer v. Chr.
string.match(dateToLink, "^[%D]+ [%d]+ v%. Chr%.$") ~= nil then
result = "[["..a[0].."]] [["..a[1].." "..a[2].."]]"
elseif -- Mount Joer (Julianesch)
string.match(dateToLink, "^[%D]+ [%d]+ %(julianesch%)$") ~= nil then
result = "[["..a[0].."]] [["..a[1].."]] <sup>[[Julianesche Kalenner|jul.]]</sup>"
elseif --Joer v. Chr. (Julianesch)
string.match(dateToLink, "^[%d]+ v%. Chr%. %(julianesch%)$") ~= nil then
result = "[["..a[0].." "..a[1].."]] <sup>[[Julianesche Kalenner|jul.]]</sup>"
elseif -- Joerzéngt v. Chr. (Julianesch)
string.match(dateToLink, "^[%d]+er v%. Chr%. %(julianesch%)$") ~= nil then
result = a[0].." "..a[1].." <sup>[[Julianesche Kalenner|jul.]]</sup>"
elseif -- n. Joerdausend/Joerhonnert v. Chr.
string.match(dateToLink, "^[%d]+%. Joer[dh][ao][un][sn]e[nr][dt] v%. Chr%.$") ~= nil then
result = "[["..a[0].." "..a[1].." "..a[2].."]]"
elseif -- n. Joerdausend/Joerhonnert (Julianesch)
string.match(dateToLink, "^[%d]+%. Joer[dh][ao][un][sn]e[nr][dt] %(julianesch%)$") ~= nil then
result = "[["..a[0].." "..a[1].."]] <sup>[[Julianesche Kalenner|jul.]]</sup>"
else
result = dateToLink.."[[Kategorie:Brasilianesch Foussballspiller]]"
end
---- num == 2 ----
elseif num == 2 then
if -- Mount Joer
string.match(dateToLink, "^[%D]+ [%d]+$") ~= nil then
result = "[["..a[0].."]] [["..a[1].."]]"
elseif -- Joer v. Chr.
string.match(dateToLink, "^[%d]+ v%. Chr%.$") ~= nil then
result = "[["..a[0].." "..a[1].."]]"
elseif -- Joer (Julianesch)
string.match(dateToLink, "^[%d]+ %(julianesch%)$") ~= nil then
result = "[["..a[0].."]] <sup>[[Julianesche Kalenner|jul.]]</sup>"
elseif -- Joerzéngt v. Chr.
string.match(dateToLink, "^[%d]+er v%. Chr%.$") ~= nil then
result = dateToLink
elseif -- Joerzéngt (Julianesch)
string.match(dateToLink, "^[%d]+er %(julianesch%)$") ~= nil then
result = a[0].." <sup>[[Julianesche Kalenner|jul.]]</sup>"
elseif -- n. Joerdausend/Joerhonnert
string.match(dateToLink, "^[%d]+%. Joer[dh][ao][un][sn]e[nr][dt]$") ~= nil then
result = "[["..a[0].." "..a[1].."]]"
else
result = dateToLink.."[[Kategorie:Brasilianesch Foussballspiller]]"
end
---- num == 1 -----
elseif num == 1 then
if -- Joer
string.match(dateToLink, "^[%d]+$") ~= nil then
result = "[["..dateToLink.."]]"
elseif -- Joerzéngt
string.match(dateToLink, "^[%d]+er$") ~= nil then
result = dateToLink
elseif -- onbekannt
string.match(dateToLink, "^onbekannt$") ~= nil then
result = dateToLink
else
result = dateToLink.."[[Kategorie:Brasilianesch Foussballspiller]]"
end
---- every other case ----
else
result = dateToLink
end
return result
end
function fun.formatDateNotLinked(dateToFormat)
local num = 0
local result = ""
local a = {}
for i in string.gmatch(dateToFormat.args[1], "%S+") do
a[num] = i
num = num + 1
end
if num == 3 then
result = a[2]
end
return result
end
function fun.formatDates(dateToFormat)
local result = ""
for k, v in pairs(dateToFormat) do
if type(k) == "string" then
result = result .. "," .. fun.formatDateNotLinked(v)
end
end
return result
end
return fun