Dim TestTime() As String = Array As String( _
"00:17:23", "01:23:11", "07:07:94", "11:59:13", "12:00:00", "12:59:56", _
"13:00:00", "13:14:15", "16:35:00", "23:33:43", "24:23:22", _
"12:34", "no:no:no", "", "hello" _
)
For I = 0 To TestTime.Length - 1
Log(TestTime(I) & " ==> " & ReformatTime(TestTime(I)))
Next
Sub ReformatTime(T24 As String) As String
Dim T() As String = Regex.Split(":", T24)
If T.Length = 3 Then
If IsNumber(T(0)) And IsNumber(T(1)) Then
Dim Hours As Int = T(0) Mod 24
'do this before adjusting Hours number
Dim AMPM As String = "am"
If Hours >= 12 Then
AMPM = "pm"
End If
If Hours > 12 Then
Hours = Hours - 12
else if Hours = 0 Then
Hours = 12 '00 in 24h time = 12am in 12h time
End If
Return Hours & ":" & T(1) & AMPM
End If
End If
Return "expecting ""hh:mm:ss"" not """ & T24 & """" 'or some other indication that something's not right
End Sub