Modul:ISOtilNorskdato/sandkasse
Utseende
Lua-feil i Modul:Documentation, linje 388: message: type error in message cfg.module-sandbox-category (string expected, got nil).
local p = {}
local lang = mw.getContentLanguage()
function p.formatIsoDate(date)
if date:match("^%d%d%p%s%a%a%a%p%s%d%d%d%d$") then
if string.sub(date,-9,-7) == "okt" then
return string.sub(date,-13,-12) .. ". oktober " .. string.sub(date,-4,-1)
elseif string.sub(date,-9,-7) == "des" then
return string.sub(date,-13,-12) .. ". desember " .. string.sub(date,-4,-1)
else
local daymonth = lang:formatDate('j. F', date)
local year = lang:formatDate('Y', date)
assert(tonumber(year), date)
return daymonth .. " " .. year
end
elseif date:match("^%d%p%s%a%a%a%p%s%d%d%d%d$") then
if string.sub(date,-9,-7) == "okt" then
return string.sub(date,-12,-12) .. ". oktober " .. string.sub(date,-4,-1)
elseif string.sub(date,-9,-7) == "des" then
return string.sub(date,-12,-12) .. ". desember " .. string.sub(date,-4,-1)
else
local daymonth = lang:formatDate('j. F', date)
local year = lang:formatDate('Y', date)
assert(tonumber(year), date)
return daymonth .. " " .. year
end
elseif date:match("^%d%d%d%d%-%d%d%-%d%d$") or date:match("^%d%d%d%d%-%d%d%-%d$") or date:match("^%d%d%d%d%-%d%-%d%d$")
or date:match("^%d%d%p%s%oktp%s%d%d%d%d$") or date:match("^%d%d%p%s\d\e\sp%s%d%d%d%d$")
or date:match("^%d%d%d%d%-%d%-%d$") then
local daymonth = lang:formatDate('j. F', date)
local year = lang:formatDate('Y', date)
assert(tonumber(year), date)
return daymonth .. " " .. year
elseif date:match("^%d%d%d%d%-%d%d") then
if tonumber(string.sub(date,-2,-1)) > 12 then
return date
else
return lang:formatDate("F Y", date, true)
end
end
return date
end
function p.isodato(frame)
local date = mw.text.trim(frame.args[1])
return p.formatIsoDate(date)
end
return p