mirror of
https://github.com/akaAgar/the-universal-mission-for-dcs-world.git
synced 2025-11-25 19:31:01 +00:00
Added function DCSEx.string.getTimeString
This commit is contained in:
parent
ba63c5b9cd
commit
e1928722db
@ -45,6 +45,28 @@ function DCSEx.string.join(table, separator)
|
||||
return joinedString
|
||||
end
|
||||
|
||||
-- TODO: description, file header
|
||||
function DCSEx.string.getTimeString(timeInSeconds, useColon)
|
||||
timeInSeconds = timeInSeconds or timer.getAbsTime()
|
||||
useColon = useColon or false
|
||||
|
||||
timeInSeconds = math.max(0, timeInSeconds) % 86400
|
||||
|
||||
local hours = math.floor(timeInSeconds / 3600)
|
||||
local minutes = math.floor(timeInSeconds / 60 - hours * 60)
|
||||
|
||||
local hoursStr = tostring(hours)
|
||||
if #hoursStr == 1 then hoursStr = "0"..hoursStr end
|
||||
|
||||
local minutesStr = tostring(minutes)
|
||||
if #minutesStr == 1 then minutesStr = "0"..minutesStr end
|
||||
|
||||
local separator = ""
|
||||
if useColon then separator = ":" end
|
||||
|
||||
return hoursStr..separator..minutesStr
|
||||
end
|
||||
|
||||
-- TODO: description, file header
|
||||
function DCSEx.string.toStringNumber(number, firstToUpper)
|
||||
firstToUpper = firstToUpper or false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user