Skip to content

Commit 7b29cab

Browse files
committed
解决冲突
1 parent e57d1b6 commit 7b29cab

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

SomeTest/os_time/MyTimeTest.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ print(os.date("%U"))
1919
-- 组合格式化时间
2020
print(os.date("%Y-%m-%d, %H:%M:%S",os.time()))
2121

22-
print(getRemainTime("24:00:00"))
22+
print(getRemainTime(openTime))
23+
local openTime = "20:30:00"

SomeTest/os_time/timespan.lua

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
Split = function(szFullString,szSeprator)
2-
local nFindStartIndex = 1
3-
local nSplitIndex = 1
4-
local nSplitArray = {}
5-
while true do
6-
local nFindLastIndex = string.find(szFullString,szSeprator,nFindStartIndex)
7-
if not nFindLastIndex then
8-
nSplitArray[nSplitIndex] = string.sub(szFullString,nFindStartIndex,string.len(szFullString))
9-
break
10-
end
11-
nSplitArray[nSplitIndex] = string.sub(szFullString,nFindStartIndex,nFindLastIndex - 1)
12-
nFindStartIndex = nFindLastIndex + string.len(szSeprator)
13-
nSplitIndex = nSplitIndex + 1
14-
end
15-
return nSplitArray
2+
local nFindStartIndex = 1
3+
local nSplitIndex = 1
4+
local nSplitArray = {}
5+
while true do
6+
local nFindLastIndex = string.find(szFullString,szSeprator,nFindStartIndex)
7+
if not nFindLastIndex then
8+
nSplitArray[nSplitIndex] = string.sub(szFullString,nFindStartIndex,string.len(szFullString))
9+
break
10+
end
11+
nSplitArray[nSplitIndex] = string.sub(szFullString,nFindStartIndex,nFindLastIndex - 1)
12+
nFindStartIndex = nFindLastIndex + string.len(szSeprator)
13+
nSplitIndex = nSplitIndex + 1
14+
end
15+
return nSplitArray
1616
end
1717

1818
formatTime = function( timeStr )
19-
local splited = Split(timeStr, ":")
20-
local h = splited[1]
21-
local m = splited[2]
22-
return tonumber(h), tonumber(m)
19+
local splited = Split(timeStr, ":")
20+
local h = splited[1]
21+
local m = splited[2]
22+
return tonumber(h), tonumber(m)
2323
end
2424

2525
getRemainTime = function(timeStr)
26-
local h1, m1 = formatTime(timeStr)
27-
local curTime = os.date("*t", os.time())
28-
local curH = curTime.hour
29-
local curM = curTime.min
26+
local h1, m1 = formatTime(timeStr)
27+
local curTime = os.date("*t", os.time())
28+
local curH = curTime.hour
29+
local curM = curTime.min
3030

31-
local remainH = h1 - curH
32-
local remainM = m1 - curM
33-
local totalRemainSeCond = remainH * 3600 + remainM * 60
34-
return totalRemainSeCond
31+
local remainH = h1 - curH
32+
local remainM = m1 - curM
33+
local totalRemainSeCond = remainH * 3600 + remainM * 60
34+
return totalRemainSeCond
3535
end

0 commit comments

Comments
 (0)