Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function formatSeconds(nSeconds)
- local nSec = nSeconds % 60
- local nMin = math.floor((nSeconds / 60) % 60)
- local nHour = math.floor((nSeconds / 3600) % 24)
- local nDay = math.floor(nSeconds / 86400)
- local sReturnString = string.format("%02d:%02d:%02d:%02d", nDay, nHour, nMin, nSec)
- if nMin == 0 and nHour == 0 and nDay == 0 then
- sReturnString = string.format("%02d:%02d", nMin, nSec)
- elseif nHour == 0 and nDay == 0 then
- sReturnString = string.format("%02d:%02d", nMin, nSec)
- elseif nDay == 0 then
- sReturnString = string.format("%02d:%02d:%02d", nHour, nMin, nSec)
- end
- return sReturnString
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement