Silence crash in TMainForm.AnyGridGetText, when trying to calculate Unix timestamp from an too large or too low number

This commit is contained in:
Ansgar Becker
2020-12-14 19:56:55 +01:00
parent 85dcfc7108
commit cb85ad596d

View File

@ -9738,12 +9738,15 @@ begin
end else if HandleUnixTimestampColumn(Sender, Column) then begin
try
Timestamp := Trunc(StrToFloat(Results.Col(Column), FFormatSettings));
Dec(Timestamp, FTimeZoneOffset);
CellText := DateTimeToStr(UnixToDateTime(Timestamp));
except
// EConvertError in StrToFloat or EInvalidOp in Trunc or...
Timestamp := 0;
on E:Exception do begin
CellText := Results.Col(Column);
LogSQL('Error when calculating Unix timestamp from "'+CellText+'": '+E.Message, lcError);
end;
end;
Dec(Timestamp, FTimeZoneOffset);
CellText := DateTimeToStr(UnixToDateTime(Timestamp));
end else begin
if DataLocalNumberFormat and (not EditingAndFocused) then
CellText := FormatNumber(Results.Col(Column), True)