Permalink
Browse files

Display tenths of a second through FormatTimeNumber. Used by query ru…

…nning status, table tools dialog and some more.
  • Loading branch information...
ansgarbecker committed Mar 18, 2018
1 parent de0446b commit 83d6b02d7c2b38afc8b7199e94e5d1a4a04132a5
Showing with 24 additions and 17 deletions.
  1. +18 −11 source/apphelpers.pas
  2. +1 −1 source/dbconnection.pas
  3. +3 −3 source/main.pas
  4. +2 −2 source/tabletools.pas
@@ -282,7 +282,7 @@ TAppSettings = class(TObject)
function RegExprGetMatch(Expression: String; var Input: String; ReturnMatchNum: Integer; DeleteFromSource: Boolean): String;
function FormatByteNumber( Bytes: Int64; Decimals: Byte = 1 ): String; Overload;
function FormatByteNumber( Bytes: String; Decimals: Byte = 1 ): String; Overload;
function FormatTimeNumber(Seconds: Cardinal; DisplaySeconds: Boolean): String;
function FormatTimeNumber(Seconds: Double; DisplaySeconds: Boolean): String;
function GetTempDir: String;
procedure SaveUnicodeFile(Filename: String; Text: String);
procedure OpenTextFile(const Filename: String; out Stream: TFileStream; var Encoding: TEncoding);
@@ -1078,27 +1078,34 @@ function FormatByteNumber( Bytes: String; Decimals: Byte = 1 ): String; Overload
@param Cardinal Number of seconds
@result String 12:34:56
}
function FormatTimeNumber(Seconds: Cardinal; DisplaySeconds: Boolean): String;
function FormatTimeNumber(Seconds: Double; DisplaySeconds: Boolean): String;
var
d, h, m, s : Integer;
d, h, m, s, ts: Integer;
begin
s := Seconds;
s := Trunc(Seconds);
ts := Trunc((Seconds - s) * 10); // ts = tenth of a second
d := s div (60*60*24);
s := s mod (60*60*24);
h := s div (60*60);
s := s mod (60*60);
m := s div 60;
s := s mod 60;
if d > 0 then begin
if DisplaySeconds then
Result := Format('%d '+_('days')+', %.2d:%.2d:%.2d', [d, h, m, s])
else
if DisplaySeconds then begin
Result := Format('%d '+_('days')+', %.2d:%.2d:%.2d', [d, h, m, s]);
Result := Result + '.' + IntToStr(ts);
end
else begin
Result := Format('%d '+_('days')+', %.2d:%.2d h', [d, h, m]);
end;
end else begin
if DisplaySeconds then
Result := Format('%.2d:%.2d:%.2d', [h, m, s])
else
Result := Format('%.2d:%.2d h', [h, m])
if DisplaySeconds then begin
Result := Format('%.2d:%.2d:%.2d', [h, m, s]);
Result := Result + '.' + IntToStr(ts);
end
else begin
Result := Format('%.2d:%.2d h', [h, m]);
end;
end;
end;
@@ -4869,7 +4869,7 @@ function TDBConnection.ConnectionInfo: TStringList;
if rx.Exec(Infos) then while True do begin
Val := rx.Match[2];
if LowerCase(rx.Match[1]) = 'uptime' then
Val := FormatTimeNumber(StrToIntDef(Val, 0), True)
Val := FormatTimeNumber(StrToFloatDef(Val, 0), True)
else
Val := FormatNumber(Val);
Result.Values[_(rx.Match[1])] := Val;
@@ -2841,7 +2841,7 @@ procedure TMainForm.FinishedQueryExecution(Thread: TQueryThread);
if Thread.QueryTime < 60*1000 then
MetaInfo := MetaInfo + ': '+FormatNumber(Thread.QueryTime/1000, 3) +' sec.'
else
MetaInfo := MetaInfo + ': '+FormatTimeNumber(Thread.QueryTime div 1000, True);
MetaInfo := MetaInfo + ': '+FormatTimeNumber(Thread.QueryTime/1000, True);
if Thread.QueryNetTime > 0 then
MetaInfo := MetaInfo + ' (+ '+FormatNumber(Thread.QueryNetTime/1000, 3) +' sec. network)';
LogSQL(MetaInfo);
@@ -12565,8 +12565,8 @@ procedure TQueryTab.TimerStatusUpdateOnTimer(Sender: TObject);
Msg := _('query')+' #' + FormatNumber(ExecutionThread.BatchPosition+1);
if ExecutionThread.QueriesInPacket > 1 then
Msg := f_('queries #%s to #%s', [FormatNumber(ExecutionThread.BatchPosition+1), FormatNumber(ExecutionThread.BatchPosition+ExecutionThread.QueriesInPacket)]);
Elapsed := SecondsBetween(ExecutionThread.QueryStartedAt, Now);
ElapsedMsg := FormatTimeNumber(Elapsed, True);
Elapsed := MilliSecondsBetween(ExecutionThread.QueryStartedAt, Now);
ElapsedMsg := FormatTimeNumber(Elapsed/1000, True);
MainForm.ShowStatusMsg(ElapsedMsg + ': ' + f_('Executing %s of %s ...', [Msg, FormatNumber(ExecutionThread.Batch.Count)]));
end;
@@ -748,7 +748,7 @@ procedure TfrmTableTools.Execute(Sender: TObject);
DeleteFile(FileName);
LogRow := FResults.Last;
LogRow[2] := _('Compressing done.');
LogRow[3] := FormatTimeNumber((GetTickCount-StartTime) DIV 1000, True);
LogRow[3] := FormatTimeNumber((GetTickCount-StartTime) / 1000, True);
ResultGrid.Repaint;
end;
@@ -1352,7 +1352,7 @@ procedure TfrmTableTools.DoExport(DBObj: TDBObject);
BytesDone := Max(DBObj.Size,0) div Max(DBObj.Rows,1) * RowsDone;
FObjectSizesDoneExact := FObjectSizesDone + BytesDone;
LogRow[2] := FormatNumber(RowsDone) + ' / ' + FormatNumber(Percent, 0)+'%';
LogRow[3] := FormatTimeNumber((GetTickCount-StartTime) DIV 1000, True);
LogRow[3] := FormatTimeNumber((GetTickCount-StartTime) / 1000, True);
UpdateResultGrid;
end;

0 comments on commit 83d6b02

Please sign in to comment.