Rich
2009-08-26 18:40:30
{*******************************************************************************
function IntToTime(MS : Integer) : string;
By: R1ch
Description: Converts MS to H/M/S/MS time
*******************************************************************************}
function IntToTime(MS : Integer) : string;
var
I : Integer;
HMS, HMSc : TIntegerArray;
begin
HMS:= [1000, 60000, 3600000];
SetLength(HMSc, 3);
for I:= 2 downto 0 do
begin
repeat
if (MS > HMS[I]) then
begin
MS:= MS - HMS[I];
Inc(HMSc[I]);
end;
until(MS < HMS[I]);
end;
Result:= (IntToStr(HMSc[2]) + ' Hours, ' + IntToStr(HMSc[1]) + ' Minutes, ' + IntToStr(HMSc[0]) + ' Seconds and ' + IntToStr(MS) + ' Milliseconds');
end;Converts milliseconds to hours, minutes, seconds and milliseconds.
Example:
IntToTime(5214622);
outputs
1 Hours, 26 Minutes, 54 Seconds and 622 Milliseconds
It is used like:
WriteLn(IntToTime(5214622));Richard.