mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Consistently use FormatTimeNumber() also for formatting server uptime. Leave out the day portion if zero.
This commit is contained in:
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user