TimeType=class("TimeType")
--获取 00:00:00 时间格式
function TimeType:getTimeString(second)
local s=second%60
local min=math.floor(second/60)%60
local h=math.floor(second/3600)
local secondBody
local minuteBody
local hourBody
if h==0 and min==0 and s==0 then
secondBody="00"
elseif s<10 then
secondBody="0"..s
else
secondBody=s
end
if h==0 and min==0 then
minuteBody="00:"
elseif min<10 then
minuteBody="0"..min..":"
else
minuteBody=min..":"
end
if h==0 then
hourBody="00:"
elseif h<10 then
hourBody="0"..h..":"
else
hourBody=h..":"
end
return hourBody..minuteBody..secondBody
end
---获取 00:00 时间格式
function TimeType:getShortTimeString(second)
if second>3600 then
return TimeType:getTimeString(second)
else
local s=second%60
local min=math.floor(second/60)%60
local secondBody
local minuteBody
if h==0 and min==0 and s==0 then
secondBody="00"
elseif s<10 then
secondBody="0"..s
else
secondBody=s
end
if h==0 and min==0 then
minuteBody="00"
elseif min<10 then
minuteBody="0"..min..":"
else
minuteBody=min..":"
cocos2dx,lua,倒计时的应用
最新推荐文章于 2019-09-07 20:10:20 发布