Merchants Posted August 26, 2012 Share Posted August 26, 2012 i some of a converter for my output string...i have this as a input(Time formation)01:10:47 (1m 10s 47ms)/72:47:47(1h 12m 47s 47ms )this is the lengt of the output Formation: 0:00:00.00so what i want as results like this:Input: 01:10:47Output: 0:01:10:47/Input: 72:47:47Output: 1:12:47.47 Link to comment Share on other sites More sharing options...
czardas Posted August 26, 2012 Share Posted August 26, 2012 (edited) How about this? Dim $Input = "72:47:47" Dim $split = StringSplit($Input,":") $split[0] = Floor($split[1]/60) $split[1] -= $split[0]*60 Dim $Output = $split[0] & ":" & $split[1] & ":" & $split[2] & "." & $split[3] MsgBox(0, "Result", $Output) ; 1:12:47.47 Edited August 27, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Malkey Posted August 27, 2012 Share Posted August 27, 2012 And this works also. Local $sTime = "72:47:8" Local $sReformatedTime = Execute(StringRegExpReplace($sTime, "(d{0,2}):(d{0,2}):(d{0,2})", _ 'StringFormat("%s:%02s:%02s:%02s", int($1/60), mod($1,60), $2, $3)')) ;or ConsoleWrite(Execute(StringRegExpReplace($sTime, "(d{0,2}):(d{0,2}):(d{0,2})", _ 'int($1/60) & ":" & StringRight("00" & mod($1,60),2) & ":" & StringRight("00" & $2,2) & ":" & StringRight("00" & $3,2)')) & @LF) MsgBox(0, "Result", $sReformatedTime) ; 1:12:47:08 Link to comment Share on other sites More sharing options...
Merchants Posted August 27, 2012 Author Share Posted August 27, 2012 ok very goodit still have a need of a fixon this time works fine: 01:10:47this one not: 01:10.47this one not: 1:12:47.47 Link to comment Share on other sites More sharing options...
Spiff59 Posted August 27, 2012 Share Posted August 27, 2012 (edited) If your last field represents milliseconds, then shouldn't your desired output be: 01:12:47.047 ? I'm not sure your output examples, nor the two code examples, correctly display milliseconds. What you refer to as 47ms in the original post is not .47 seconds (470ms). Edit: Maybe your input source is actually centiseconds and not milliseconds? I don't know, but something is not Kosher about the OP's description of the problem. Edited August 27, 2012 by Spiff59 czardas 1 Link to comment Share on other sites More sharing options...
czardas Posted August 27, 2012 Share Posted August 27, 2012 (edited) Dim $Input, $split, $iBound, $start, $Output $Input = "1:02:47:47" $split = StringSplit($Input,":.") $iBound = $split[0] If $iBound = 3 Then $split[0] = Floor($split[1]/60) $split[1] -= $split[0]*60 $start = 0 Else $start = 1 EndIf $Output = $split[$start] For $i = $start +1 To $iBound -1 $Output &= ":" & $split[$i] Next $Output &= "." & $split[$iBound] MsgBox(0, "Result", $Output) ; 1:02:47.47 Please try to be clear about all the expected results when you ask a question. I know it's sometimes complicated to explain things. Is this any better? Edited August 27, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Merchants Posted August 27, 2012 Author Share Posted August 27, 2012 no nvm the last request ty u for the help guys Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now