Jump to content

Module:AgeTemplate: Difference between revisions

From Marxist Wiki
Created page with "local p = {} local function isLeapYear(Year) if Year%400 == 0 then return true end if Year%4 == 0 and Year%100 ~= 0 then return true end return false end 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..."
 
m Protected "Module:AgeTemplate" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
 
(No difference)

Latest revision as of 23:38, 12 March 2025

Documentation for this module may be created at Module:AgeTemplate/doc

local p = {}

local function isLeapYear(Year)
	if Year%400 == 0 then
		return true
	end
	if Year%4 == 0 and Year%100 ~= 0 then
		return true
	end
	return false
end

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