I need to go from milliseconds to a tuple of (hour, minutes, seconds, milliseconds) representing the same amount of time. E.g.:
10799999ms = 2h 59m 59s 999ms
milliseconds = 12884983 // or x milliseconds
hr = 0
min = 0
sec = 0
day = 0
while (milliseconds >= 1000) {
milliseconds = (milliseconds - 1000)
sec = sec + 1
if (sec >= 60) min = min + 1
if (sec == 60) sec = 0
if (min >= 60) hr = hr + 1
if (min == 60) min = 0
if (hr >= 24) {
hr = (hr - 24)
day = day + 1
}
}
I hope that my shorter method will help you