lua时间工具

分享几个lua的时间的方法


function TimeTool:time(second_)
	if second_>=3600*24 then
		return string.format("%dd %02d:%02d:%02d", math.floor(second_/ (3600*24) ), math.floor((second_%(3600*24))/3600), math.floor((second_%3600)/60), math.floor(second_%60))
	elseif second_>=3600 then
		return string.format("%02d:%02d:%02d", math.floor(second_/3600), math.floor((second_%3600)/60), math.floor(second_%60))
	elseif second_>=60 then
		return string.format("%02d:%02d", math.floor(second_/60), math.floor(second_%60))
	end
	if second_ < 0 then second_ = 0 end
	return string.format("00:%02d", math.floor(second_))
end



function TimeTool:costTime(second_)
	return string.format("%02d:%02d:%02d", math.floor(second_/3600), math.floor((second_%3600)/60), math.floor(second_%60))
end

猜你喜欢

转载自caiwb1990.iteye.com/blog/2342822