1
1
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
16
16
end
17
17
18
18
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 )
23
23
end
24
24
25
25
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
30
30
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
35
35
end
0 commit comments