Module:DateDiff

Revision as of 00:06, 24 June 2023 by MENDES (talk | contribs) (Protected "Module:DateDiff": structural page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local p={}
local function _DateDiff(y1,m1,d1,y2,m2,d2)
	fromdate = os.time{year=y1,month=m1,day=d1,hour=16} -- 7:00 AM UTC+9
	if y2 ~= nil then
		todate = os.time{year=y2,month=m2,day=d2,hour=16} -- 7:00 AM UTC+9
	else
		todate = os.time()
	end
	diff = math.floor(os.difftime(todate,fromdate) / 86400)
	return diff
end

function p.DateDiff(frame)
	args=frame:getParent().args
	return _DateDiff(args[1],args[2],args[3],args[4],args[5],args[6])
end
return p