Added function DCSEx.string.getTimeString

This commit is contained in:
Ambroise Garel 2025-07-29 14:03:03 +02:00
parent ba63c5b9cd
commit e1928722db

View File

@ -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