mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Support all integer and real data types for displaying as Unix timestamp. See http://www.heidisql.com/forum.php?t=22092
This commit is contained in:
@@ -250,8 +250,8 @@ type
|
||||
function EncodeURLParam(const Value: String): String;
|
||||
procedure StreamWrite(S: TStream; Text: String = '');
|
||||
function _GetFileSize(Filename: String): Int64;
|
||||
function MakeInt( Str: String ) : Int64;
|
||||
function MakeFloat( Str: String ): Extended;
|
||||
function MakeInt(Str: String; FromLocaleFormat: Boolean=True) : Int64;
|
||||
function MakeFloat(Str: String; FromLocaleFormat: Boolean=True): Extended;
|
||||
function CleanupNumber(Str: String): String;
|
||||
function IsNumeric(Str: String): Boolean;
|
||||
function esc(Text: String; ProcessJokerChars: Boolean=false; DoQuote: Boolean=True): String;
|
||||
@@ -555,11 +555,11 @@ end;
|
||||
@param string String-number
|
||||
@return int64
|
||||
}
|
||||
function MakeInt(Str: String): Int64;
|
||||
function MakeInt(Str: String; FromLocaleFormat: Boolean=True): Int64;
|
||||
begin
|
||||
// Result has to be of integer type
|
||||
try
|
||||
Result := Trunc(MakeFloat(Str));
|
||||
Result := Trunc(MakeFloat(Str, FromLocaleFormat));
|
||||
except
|
||||
Result := 0;
|
||||
end;
|
||||
@@ -617,13 +617,15 @@ end;
|
||||
@param String text representation of a number
|
||||
@return Extended
|
||||
}
|
||||
function MakeFloat( Str: String ): Extended;
|
||||
function MakeFloat(Str: String; FromLocaleFormat: Boolean=True): Extended;
|
||||
var
|
||||
p_kb, p_mb, p_gb, p_tb, p_pb : Integer;
|
||||
begin
|
||||
// Convert result to a floating point value to ensure
|
||||
// we don't discard decimal digits for the next step
|
||||
Result := StrToFloat(CleanupNumber(Str));
|
||||
if FromLocaleFormat then
|
||||
Str := CleanupNumber(Str);
|
||||
Result := StrToFloat(Str);
|
||||
|
||||
// Detect if the string was previously formatted by FormatByteNumber
|
||||
// and convert it back by multiplying it with its byte unit
|
||||
|
||||
@@ -2344,7 +2344,7 @@ begin
|
||||
// Shorthand for various places where we would normally have to add all these conditions
|
||||
Result := (Sender = DataGrid)
|
||||
and (Column > NoColumn)
|
||||
and (DataGridResult.DataType(Column).Index in [dtInt, dtBigint])
|
||||
and (DataGridResult.DataType(Column).Category in [dtcInteger, dtcReal])
|
||||
and (SelectedTableTimestampColumns.IndexOf(DataGrid.Header.Columns[Column].Text) > -1);
|
||||
end;
|
||||
|
||||
@@ -5361,7 +5361,7 @@ begin
|
||||
Results.RecNo := RowNum^;
|
||||
GridHasChanges := Results.Modified or Results.Inserted;
|
||||
if Grid.FocusedColumn > NoColumn then
|
||||
EnableTimestamp := Results.DataType(Grid.FocusedColumn).Index in [dtInt, dtBigint];
|
||||
EnableTimestamp := Results.DataType(Grid.FocusedColumn).Category in [dtcInteger, dtcReal];
|
||||
end;
|
||||
end;
|
||||
inDataTab := PageControlMain.ActivePage = tabData;
|
||||
@@ -8450,7 +8450,7 @@ begin
|
||||
if FGridCopying then begin
|
||||
CellText := Results.Col(Column);
|
||||
end else if HandleUnixTimestampColumn(Sender, Column) then begin
|
||||
Timestamp := MakeInt(Results.Col(Column));
|
||||
Timestamp := MakeInt(Results.Col(Column), False);
|
||||
Dec(Timestamp, FTimeZoneOffset);
|
||||
CellText := DateTimeToStr(UnixToDateTime(Timestamp));
|
||||
end else begin
|
||||
|
||||
Reference in New Issue
Block a user