Sub calchourstring(old As Int) As String
'Log("int 1242 0h 20m 42s")
Dim h As Int = Abs(old/3600)
Log(h)
Dim m As Int = Abs((old-(h*3600))/60)
Log(m)
'Log("test "&((h*3600)+(m*60)))
Dim s As Int = Abs( old-((h*3600)+(m*60)) )
Log(s)
Return NumberFormat(h,2,0)&":"&NumberFormat(m,2,0)&":"&NumberFormat(s,2,0)
End Sub
Sub calcseconds(hourstring As String) As Int
Dim c() As String =Regex.Split(":",hourstring)
Return (c(0)*3600)+(c(1)*60)+c(2)
End Sub
Log(calchourstring(1242))
Log(calcseconds(calchourstring(1242)))
Sub calchourstring(old As Int) As String
'Log("int 1242 0h 20m 42s")
Dim s As Int = old Mod 3600 'seconds without hours
Dim h As Int = old/3600 'no Abs() needed because stored in Int variable
Dim m As Int = s/60
s = s Mod 60
Log(h)
Log(m)
Log(s)
Return NumberFormat(h,2,0)&":"&NumberFormat(m,2,0)&":"&NumberFormat(s,2,0)
End Sub
ABS = Absolute Number, i guess you meant "Floor"!!
i would recommend to work with ticks whenever you want to get time/date.
so this could be also a possibility:
B4X:
Dim seconds As Int = 1242 * DateTime.TicksPerSecond 'convert seconds to ticks!
Log("Days: " & Floor(seconds/DateTime.TicksPerDay))
Log("Hours: " & Floor(seconds/DateTime.TicksPerHour Mod 24))
Log("Minutes: " & Floor(seconds/DateTime.TicksPerMinute Mod 60))
Log("Seconds: " & Floor(seconds/DateTime.TicksPerSecond Mod 60))
Waiting for debugger to connect...
Program started.
Days: 0
Hours: 0
Minutes: 20
Seconds: 42