Consistently use FormatTimeNumber() also for formatting server uptime. Leave out the day portion if zero.

This commit is contained in:
Ansgar Becker
2009-11-23 21:24:25 +00:00
parent db3fbd0df7
commit cdb936b77d
2 changed files with 12 additions and 16 deletions

View File

@ -2036,14 +2036,19 @@ end;
} }
function FormatTimeNumber( Seconds: Cardinal ): String; function FormatTimeNumber( Seconds: Cardinal ): String;
var var
h, m, s : Integer; d, h, m, s : Integer;
begin begin
s := Seconds mod (60*60*24); s := Seconds;
d := s div (60*60*24);
s := s mod (60*60*24);
h := s div (60*60); h := s div (60*60);
s := s mod (60*60); s := s mod (60*60);
m := s div 60; m := s div 60;
s := s mod 60; s := s mod 60;
Result := Format('%.2d:%.2d:%.2d', [h, m, s]); if d > 0 then
Result := Format('%d days, %.2d:%.2d:%.2d', [d, h, m, s])
else
Result := Format('%.2d:%.2d:%.2d', [h, m, s]);
end; end;

View File

@ -4277,20 +4277,11 @@ end;
procedure TMainForm.TimerHostUptimeTimer(Sender: TObject); procedure TMainForm.TimerHostUptimeTimer(Sender: TObject);
var
ServerUptime, days, hours, minutes, seconds : Integer;
begin begin
// Host-Uptime // Display server uptime
if Assigned(Connection) then begin if Assigned(Connection) then
ServerUptime := Connection.ServerUptime; showstatus('Uptime: '+FormatTimeNumber(Connection.ServerUptime), 4)
days:= ServerUptime div (60*60*24); else
seconds := ServerUptime mod (60*60*24);
hours := seconds div (60*60);
seconds := seconds mod (60*60);
minutes := seconds div 60;
seconds := seconds mod 60;
showstatus(Format('Uptime: %d days, %.2d:%.2d:%.2d', [days,hours,minutes,seconds]), 4);
end else
showstatus('', 4); showstatus('', 4);
end; end;