mirror of
https://github.com/akaAgar/the-universal-mission-for-dcs-world.git
synced 2026-08-24 18:25:18 +00:00
Added function DCSEx.string.getTimeString
This commit is contained in:
@@ -45,6 +45,28 @@ function DCSEx.string.join(table, separator)
|
|||||||
return joinedString
|
return joinedString
|
||||||
end
|
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
|
-- TODO: description, file header
|
||||||
function DCSEx.string.toStringNumber(number, firstToUpper)
|
function DCSEx.string.toStringNumber(number, firstToUpper)
|
||||||
firstToUpper = firstToUpper or false
|
firstToUpper = firstToUpper or false
|
||||||
|
|||||||
Reference in New Issue
Block a user