Modul:LinkSubformDatum: Unterschied zwischen den Versionen

K
Entfernte den Schutz von „Modul:LinkSubformDatum
Keine Bearbeitungszusammenfassung
K (Entfernte den Schutz von „Modul:LinkSubformDatum“)
 
(7 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 4: Zeile 4:


function p.GetMonthday(frame)
function p.GetMonthday(frame)
pf = frame:getParent()
-- #invoke wrapper
args = pf.args
return p.getMonthday(frame.args[1])
date = args[1]
return get_monthday(date)
end
end


function get_monthday(date)
function p.getMonthday(date)
months=c.getMonthList()
local months = c.getMonthList()
date_array=str.split(date, "/")
local date_array = str.split(date, "/")
if c.isEmpty(date_array[1]) then
if c.isEmpty(date_array[2]) then
-- When datestring contained no "/"
-- When datestring contained no "/"
mda = str.split(date_array[0])
local mda = str.split(date_array[1])
if c.isEmpty(mda[1]) then
if c.isEmpty(mda[2]) then
-- When dateformat is just YYYY
-- When dateformat is just YYYY
return ""
return ""
else
else
-- Dateformat is <monthname> YYYY
-- Dateformat is <monthname> YYYY
return mda[0]
return mda[1]
end
end
else
else
mn = months[tonumber(date_array[1])]
mn = months[tonumber(date_array[2])]
date_array[2] = date_array[2]:gsub('0*', '', 1)
date_array[3] = date_array[3]:gsub('0*', '', 1)
return date_array[2]:gsub("%s+", "") .. ". " .. mn
return date_array[3]:gsub("%s+", "") .. ". " .. mn
end
end
end
end


function p.GetYear(frame)
function p.GetYear(frame)
args = frame.args
-- #invoke wrapper
date = args[1]
return p.getYear(frame.args[1])
return get_year(date)
end
end


function get_year(date)
function p.getYear(date)
date_array=str.split(date, "/")
local date_array=str.split(date, "/")
if c.isEmpty(date_array[1]) then
if c.isEmpty(date_array[2]) then
-- When datestring contained no "/"
-- When datestring contained no "/"
mda = str.split(date_array[0])
local mda = str.split(date_array[1])
if c.isEmpty(mda[1]) then
if c.isEmpty(mda[2]) then
-- When dateformat is just YYYY
-- When dateformat is just YYYY
return mda[0]
return mda[1]
else
else
-- Dateformat is <monthname> YYYY
-- Dateformat is <monthname> YYYY
return mda[1]
return mda[2]
end
end
elseif c.isEmpty(date_array[2]) then
elseif c.isEmpty(date_array[3]) then
-- Datestring contained one "/"
-- Datestring contained one "/"
return date_array[0]
return date_array[1]
else
else
-- Dateformat should be YYYY/MM/DD
-- Dateformat should be YYYY/MM/DD
return date_array[0]
return date_array[1]
end
end
end
end


return p
return p