Module:AgeTemplate: Difference between revisions

From ProleWiki, the proletarian encyclopedia
m (Making arguments read strings instead of numbers to see if it works)
m (Further development. Testing capture of year, month and day)
Line 9: Line 9:
if arg1 == "1" or arg1 == "2" or arg1 == "3" then
if arg1 == "1" or arg1 == "2" or arg1 == "3" then
return "1, 2 or 3 in first argument"
local initialDate = pframe.args[2]
else
else
return "Not 1, nor 2 or 3 in first argument"
local initialDate = pframe.args[1]
end
end
local year,month,day = string.match(initialDate, '(%d+)-(%d+)-(%d+)')
return "Year: " .. year .. ", Month: " .. month .. ", Day: " .. day
end
end
return p
return p

Revision as of 14:47, 3 September 2022

local p = {}

function p.age( frame )
	local pframe = frame:getParent()
	
	local arg1 = pframe.args[1]
	local arg2 = pframe.args[2]
	local arg3 = pframe.args[3]
	
	if arg1 == "1" or arg1 == "2" or arg1 == "3" then
		local initialDate = pframe.args[2]
		else
			local initialDate = pframe.args[1]
	end
	local year,month,day = string.match(initialDate, '(%d+)-(%d+)-(%d+)')
	return "Year: " .. year .. ", Month: " .. month .. ", Day: " .. day
end
return p