推奨読書:
A. 2時01日間1日より長い表示を変換するために夜12時00分〇〇秒秒
local function second2DHMS(second)
if second <= 0 then
return 0,0,0,0
end
local d = math.floor(second / 86400)
second = second - d * 86400
local h = math.floor(second / 3600)
second = second - h * 3600
local m = math.floor(second / 60)
second = second - m * 60
local s = second
return d, h, m, s
end
local function gettimestrDay(second)
local _d, _h, _m, _s =second2DHMS(second)
local timedata = ""
if _d > 0 then
timedata = _d.."天".._h.."小时"
else
if _h < 10 then
_h = "0".._h
end
if _m < 10 then
_m = "0".._m
end
if _s < 10 then
_s = "0".._s
end
timedata = _h..":".._m..":".._s
end
return timedata
end
II。夜12時00分00秒に秒を変換します
-- 把秒数转换成 00:00:00
local function gettimestr(second)
local hour = math.floor(second / 3600)
local min = math.floor(second % 3600 / 60)
local sec = second % 60
return string.format("%02d:%02d:%02d", hour, min, sec)
end
III。夜12時00分00秒に秒を変換します
local function gettimestr1(second)
local hour = math.floor(second / 3600)
local min = math.floor(second % 3600 / 60)
local sec = second % 60
return string.format("%02d:%02d:%02d", hour, min, sec)
end
IV。改宗分の秒数:秒00:00
local function gettimestr2(second)
local min = math.floor(second/60)
local sec = second % 60
return string.format("%02d:%02d", min, sec)
end
V. 時間に秒を変換:分夜12時
local function gettimestr3(second)
local hour = math.floor(second / 3600)
local min = math.floor(second % 3600 / 60)
return string.format("%02d:%02d", hour, min)
end
VI。x時間に変換分までの秒数X
local function gettimestr4(second)
local hour = math.floor(second / 3600)
local min = math.floor(second % 3600 / 60)
if hour > 0 then
return string.format("%d小时%d分钟", hour, min)
end
return string.format("%d分钟", min)
end
VII。時間の秒数は、X X X分秒に変身します
local function gettimestr5(second)
local hour = math.floor(second / 3600)
local min = math.floor(second % 3600 / 60)
local sec = second % 60
if hour > 0 then
return string.format("%d小时%d分钟%d秒", hour, min, sec)
end
return string.format("%d分钟%d秒", min, sec)
end
VIII。X日X X X分の時間を秒をオンにする秒数
local function gettimestr6(second)
local day = math.floor(second / 86400)
local hour = math.floor(second % 86400 / 3600)
local min = math.floor(second % 3600 / 60)
local sec = second % 60
return string.format("%d天%d小时%d分钟%d秒", day, hour, min, sec)
end
IX。秒数は、x日x時間をオンにします
local function gettimestr7(second)
local day = math.floor(second / 86400)
local hour = math.floor(second % 86400 / 3600)
return string.format("%d天%d小时", day, hour)
end
テン。X日オンにする秒数
local function gettimestr8(second)
local day = math.floor(second / 86400)
local hour = math.floor(second % 86400 / 3600)
return string.format("%d天", day)
end