Module:AgeTemplate: Difference between revisions

From ProleWiki, the proletarian encyclopedia
m (Restored commented code after figuring it out)
m (Initialized endDate. Will leave it like this as I need to study the implementation of date differences further)
Line 9: Line 9:
local initialDate = ""
local initialDate = ""
local endDate = ""
if arg1 == "1" or arg1 == "2" or arg1 == "3" then
if arg1 == "1" or arg1 == "2" or arg1 == "3" then
initialDate = arg2
initialDate = arg2
endDate = arg3
else
else
initialDate = arg1
initialDate = arg1
endDate = arg2
end
end
local year,month,day = string.match(initialDate, '(%d+)-(%d+)-(%d+)')
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 15:08, 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]
	
	local initialDate = ""
	local endDate = ""
	if arg1 == "1" or arg1 == "2" or arg1 == "3" then
		initialDate = arg2
		endDate = arg3
		else
			initialDate = arg1
			endDate = arg2
	end
	local year,month,day = string.match(initialDate, '(%d+)-(%d+)-(%d+)')
end
return p