>>Bill,
>>
>>* hhmmss.prg 10-Oct-94
>>*function hhmmss && 13-Feb-95 for factor of 5 speed improvement
>>parameter pnElapsed
>>
>>local lnHours, lnMinutes, lnSeconds, lnElapsed, lcHHMMSS
>>
>>lnElapsed = pnElapsed
>>
>>lnHourDigits = max( 2, iif( ( lnElapsed > 0 ), int( log10( lnElapsed / 360 ) ), 0 ) )
>>
>>lnHours = int( lnElapsed / 3600 )
>>lnElapsed = lnElapsed % 3600
>>
>>lnMinutes = int( lnElapsed / 60 )
>>lnSeconds = lnElapsed % 60
>>
>>lcHHMMSS = padl( lnHours, lnHourDigits, '0' ) + ':' + padl( lnMinutes, 2, '0' ) + ':' + padl( lnSeconds, 2, '0' )
>>return lcHHMMSS
>>
>>>Does any one know of a function tha converts seconds to hh:mm:ss format. For example: 110 seconds would be 00:01:50.
>
>Dave,
> It works better than the one I had from Rubel's Power Tools. Speed is of the enhance for what I need it for.
>
>Thanks,
Bill,
I get back to the TIM_FormatMilli() function. I have tried the code of David and compared it to TIM_FormatMilli(). Here's the code I have tried. It does look like a serious benchmark but it gives you a precise trend :
tNow = SYS_GetTickCount()
? hhmmss( 110000 ) && returns 00:01:50
FOR i = 1 TO 1000
hhmmss( 110000 )
NEXT
? SYS_GetTickCount() - tNow && returns 180 (on my PC)
tNow = SYS_GetTickCount() && returns 00:01:50.000
? TIM_FormatMilli( 110000 )
FOR i = 1 TO 1000
TIM_FormatMilli( 110000 )
NEXT
? SYS_GetTickCount() - tNow && returns 60 (on my PC)
* hhmmss.prg 10-Oct-94
function hhmmss
parameter pnElapsed
local lnHours, lnMinutes, lnSeconds, lnElapsed, lcHHMMSS
lnElapsed = pnElapsed
lnHourDigits = max( 2, iif( ( lnElapsed > 0 ), int( log10( lnElapsed / 360 ) ), 0 ) )
lnHours = int( lnElapsed / 3600 )
lnElapsed = lnElapsed % 3600
lnMinutes = int( lnElapsed / 60 )
lnSeconds = lnElapsed % 60
lcHHMMSS = padl( lnHours, lnHourDigits, '0' ) + ':' + padl( lnMinutes, 2, '0' ) + ':' + padl( lnSeconds, 2, '0' )
return lcHHMMSS
This little tests tends to prove that TIM_FormatMilli() is about 3 times faster than hhmmss(). If speed if your primary goal then ...
Pat