Module:DateDiff

From SilentBlue.RemyWiki
Jump to navigation Jump to search

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