udfStrFromTimeInterval (iTimeMSec, iDigits)
;------------------------------------------------------------------------------------------------------------------------------------------
If ItemLocate("udfstrfromtimeinterval",IntControl(77,103,0,0,0),@TAB) Then Goto skip_udfstrfromtimeinterval

#DefineFunction udfStrFromTimeInterval (iTimeMSec, iDigits)
shlwapidll = StrCat(DirWindows(1),"SHLWAPI.DLL")
cchMax = DllCall(shlwapidll,long:"StrFromTimeIntervalA",lpnull,lpnull,long:iTimeMSec,long:iDigits)
hbb = BinaryAlloc(cchMax)
BinaryEodSet(hbb,cchMax)
cchMax = DllCall(shlwapidll,long:"StrFromTimeIntervalA",lpbinary:hbb,long:cchMax,long:iTimeMSec,long:iDigits)
sTime = BinaryPeekStr(hbb,0,cchMax)
BinaryFree(hbb)
Return (sTime)
;..........................................................................................................................................
; StrFromTimeInterval Function
; Converts a time interval, specified in milliseconds, to a string.
;
; Syntax
; int StrFromTimeInterval(          LPTSTR pszOut,
;     UINT cchMax,
;     DWORD dwTimeMS,
;     int digits
; );
;
; Parameters
; pszOut
; [out] Pointer to a character buffer that receives the converted string.
;
; cchMax
; [in] Size of pszOut, in characters.
; If cchMax is set to zero, StrFromTimeInterval will return the minimum size
; of the character buffer needed to hold the converted string.
; In this case, pszOut will not contain the converted string.
;
; dwTimeMS
; [in] Time interval, in milliseconds.
; digits
;
; [in] Maximum number of digits to be represented in pszOut. Some examples are: dwTimeMS digits pszOut
; 34000 3 34 sec
; 34000 2 34 sec
; 34000 1 30 sec
; 74000 3 1 min 14 sec
; 74000 2 1 min 10 sec
; 74000 1 1 min
;
; Return Value
; Returns the number of characters in pszOut, excluding the NULL terminator.
;
; Remarks
; The time value returned in pszOut will always be in the form hh hours mm minutes ss seconds.
; Times that exceed twenty four hours are not converted to days or months.
; Fractions of seconds are ignored.
;..........................................................................................................................................
#EndFunction

:skip_udfstrfromtimeinterval
;------------------------------------------------------------------------------------------------------------------------------------------



; --- test ---
; Germany country settings

iTimeMSec = 34000
iDigits   = 3
sTime11   = udfStrFromTimeInterval (iTimeMSec, iDigits) ; " 34 Sek"

iTimeMSec = 34000
iDigits   = 2
sTime12   = udfStrFromTimeInterval (iTimeMSec, iDigits) ; " 34 Sek"

iTimeMSec = 34000
iDigits   = 1
sTime13   = udfStrFromTimeInterval (iTimeMSec, iDigits) ; " 30 Sek"

iTimeMSec = 84000
iDigits   = 3
sTime21   = udfStrFromTimeInterval (iTimeMSec, iDigits) ; " 1 Min. 24 Sek"

iTimeMSec = 84000
iDigits   = 2
sTime22   = udfStrFromTimeInterval (iTimeMSec, iDigits) ; " 1 Min. 20 Sek"

iTimeMSec = 84000
iDigits   = 1
sTime23   = udfStrFromTimeInterval (iTimeMSec, iDigits) ; " 1 Min"

iTimeMSec = 1234*60*60*24*2
iDigits   = 6
sTime31   = udfStrFromTimeInterval (iTimeMSec, iDigits) ; " 59 Std. 13 Min. 55 Sek"

Exit
;------------------------------------------------------------------------------------------------------------------------------------------
;*EOF*