MSToTime, direct from Timing.scar
{*******************************************************************************
function MsToTime(MS, StrType: Integer): string;
By: ZephyrsFury, Nava2, and Rasta Magician
Description: Takes MS in milliseconds and outputs a string with hours, mins and
seconds. Different styles can be created with different StrType values:
Str Type
Time_Formal: 2 Hours, 47 Minutes and 28 Seconds
Time_Short: 02h, 47m, 28s
Time_Abbrev: 2 hr, 47 min, 28 sec
Time_Bare: 02:47:28
Time_FStop: 12.04.40
*******************************************************************************}
function MsToTime(MS, TheType: Integer): string;
var
STA: array [0..4] of TVariantArray;
Time: array [0..2] of Integer;
i: Integer;
begin
Result := '';
if (not(InRange(TheType, 0, High(STA)))) then
begin
srl_Warn('MsToTime', 'TheType: ''' + IntToStr(TheType) + ''' is not a valid value. Using Time_Bare.', warn_AllVersions);
TheType := Time_Bare;
end;
STA[Time_Formal] := [' Hours, ', ' Minutes and ', ' Seconds', False, 0];
STA[Time_Short] := ['h ', 'm ', 's', False, 2];
STA[Time_Abbrev] := [' hr ', ' min ', ' sec', False, 0];
STA[Time_Bare] := [':', ':', '', True, 2];
STA[Time_FStop] := ['.', '.', '', True, 2];
ConvertTime(MS, Time[0], Time[1], Time[2]);
for i := 0 to 2 do
if (Time[i] > 0) or (STA[TheType][3]) or (i = 2) then
Result := Result + PadZ(IntToStr(Time[i]), STA[TheType][4]) + STA[TheType][i];
end;