Modul:ISOtilNorskdato
Utsjånad
Dokumentasjon for modulen kan opprettast på Modul:ISOtilNorskdato/dok
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
end
return date
end
function p.isodato(frame)
local date = mw.text.trim(frame.args[1])
return p.formatIsoDate(date)
end
return p