SRL Archive - SRL Archives

FormatTime


Diddy Kong

2010-03-03 01:38:53

Only does HH:MM:SS format at the moment, but I can incorporate more formats into it.

function FormatTime(Time : Integer) : String;
var
Seconds, Minutes, Hours : Integer;
StringTime : String;
begin
Seconds := Floor(Time / 1000);
Hours := Floor(Seconds / 3600);
Minutes := Floor((Seconds - Hours * 3600) / 60);
Seconds := (Seconds - Hours * 3600) - Minutes * 60;
if Hours < 10 then
StringTime := '0' + IntToStr(Hours) + ':'
else
StringTime := IntToStr(Hours) + ':';
if Minutes < 10 then
Insert('0' + IntToStr(Minutes) + ':', StringTime, Length(StringTime) + 1)
else
Insert(IntToStr(Minutes), StringTime, Length(StringTime) + 1);
if Seconds < 10 then
Insert('0' + IntToStr(Seconds) + '', StringTime, Length(StringTime) + 1)
else
Insert(IntToStr(Seconds), StringTime, Length(StringTime) + 1);
Result := StringTime;
end;

Go easy on me. :p I'm just trying to contribute. :p

i luffs yeww

2010-03-03 01:53:55

I'm pretty sure this is already made. :)

Quickmarch

2010-03-03 02:28:10

Look in core/Timing.scar.