mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-16 11:42:12 +08:00
Issue #3215: Adjust date/time values converted from UNIX timestamps to use UTC time instead of local time.
This commit is contained in:
@ -935,6 +935,7 @@ type
|
|||||||
FPreferencesDialog: Toptionsform;
|
FPreferencesDialog: Toptionsform;
|
||||||
FGridEditFunctionMode: Boolean;
|
FGridEditFunctionMode: Boolean;
|
||||||
FClipboardHasNull: Boolean;
|
FClipboardHasNull: Boolean;
|
||||||
|
FTimeZoneOffset: Integer;
|
||||||
|
|
||||||
// Host subtabs backend structures
|
// Host subtabs backend structures
|
||||||
FHostListResults: TDBQueryList;
|
FHostListResults: TDBQueryList;
|
||||||
@ -1342,6 +1343,7 @@ var
|
|||||||
FunctionCategories: TStringList;
|
FunctionCategories: TStringList;
|
||||||
miGroup, miFilterGroup, miFunction, miFilterFunction: TMenuItem;
|
miGroup, miFilterGroup, miFunction, miFilterFunction: TMenuItem;
|
||||||
NTHandle: THandle;
|
NTHandle: THandle;
|
||||||
|
TZI: TTimeZoneInformation;
|
||||||
wine_nt_to_unix_file_name: procedure(p1:pointer; p2:pointer); stdcall;
|
wine_nt_to_unix_file_name: procedure(p1:pointer; p2:pointer); stdcall;
|
||||||
begin
|
begin
|
||||||
caption := APPNAME;
|
caption := APPNAME;
|
||||||
@ -1620,6 +1622,15 @@ begin
|
|||||||
FTreeRefreshInProgress := False;
|
FTreeRefreshInProgress := False;
|
||||||
|
|
||||||
FileEncodings := Explode(',', _('Auto detect (may fail)')+',ANSI,ASCII,Unicode,Unicode Big Endian,UTF-8,UTF-7');
|
FileEncodings := Explode(',', _('Auto detect (may fail)')+',ANSI,ASCII,Unicode,Unicode Big Endian,UTF-8,UTF-7');
|
||||||
|
|
||||||
|
// Detect timezone offset in seconds, once
|
||||||
|
case GetTimeZoneInformation(TZI) of
|
||||||
|
TIME_ZONE_ID_STANDARD: FTimeZoneOffset := (TZI.Bias + TZI.StandardBias);
|
||||||
|
TIME_ZONE_ID_DAYLIGHT: FTimeZoneOffset := (TZI.Bias + TZI.DaylightBias);
|
||||||
|
TIME_ZONE_ID_UNKNOWN: FTimeZoneOffset := TZI.Bias;
|
||||||
|
else RaiseLastOSError;
|
||||||
|
end;
|
||||||
|
FTimeZoneOffset := FTimeZoneOffset * 60;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -7734,6 +7745,7 @@ var
|
|||||||
EditingAndFocused: Boolean;
|
EditingAndFocused: Boolean;
|
||||||
RowNumber: PCardinal;
|
RowNumber: PCardinal;
|
||||||
Results: TDBQuery;
|
Results: TDBQuery;
|
||||||
|
Timestamp: Int64;
|
||||||
begin
|
begin
|
||||||
if Column = -1 then
|
if Column = -1 then
|
||||||
Exit;
|
Exit;
|
||||||
@ -7749,9 +7761,11 @@ begin
|
|||||||
else begin
|
else begin
|
||||||
case Results.DataType(Column).Category of
|
case Results.DataType(Column).Category of
|
||||||
dtcInteger, dtcReal: begin
|
dtcInteger, dtcReal: begin
|
||||||
if HandleUnixTimestampColumn(Sender, Column) then
|
if HandleUnixTimestampColumn(Sender, Column) then begin
|
||||||
CellText := DateTimeToStr(UnixToDateTime(MakeInt(Results.Col(Column))))
|
Timestamp := MakeInt(Results.Col(Column));
|
||||||
else
|
Dec(Timestamp, FTimeZoneOffset);
|
||||||
|
CellText := DateTimeToStr(UnixToDateTime(Timestamp));
|
||||||
|
end else
|
||||||
CellText := FormatNumber(Results.Col(Column), False);
|
CellText := FormatNumber(Results.Col(Column), False);
|
||||||
end;
|
end;
|
||||||
dtcBinary, dtcSpatial: begin
|
dtcBinary, dtcSpatial: begin
|
||||||
@ -7946,15 +7960,18 @@ procedure TMainForm.AnyGridNewText(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
|||||||
var
|
var
|
||||||
Results: TDBQuery;
|
Results: TDBQuery;
|
||||||
RowNum: PCardinal;
|
RowNum: PCardinal;
|
||||||
|
Timestamp: Int64;
|
||||||
begin
|
begin
|
||||||
Results := GridResult(Sender);
|
Results := GridResult(Sender);
|
||||||
RowNum := Sender.GetNodeData(Node);
|
RowNum := Sender.GetNodeData(Node);
|
||||||
Results.RecNo := RowNum^;
|
Results.RecNo := RowNum^;
|
||||||
try
|
try
|
||||||
if (not FGridEditFunctionMode) and (Results.DataType(Column).Category in [dtcInteger, dtcReal]) then begin
|
if (not FGridEditFunctionMode) and (Results.DataType(Column).Category in [dtcInteger, dtcReal]) then begin
|
||||||
if HandleUnixTimestampColumn(Sender, Column) then
|
if HandleUnixTimestampColumn(Sender, Column) then begin
|
||||||
NewText := IntToStr(DateTimeToUnix(StrToDateTime(NewText)))
|
Timestamp := DateTimeToUnix(StrToDateTime(NewText));
|
||||||
else
|
Inc(Timestamp, FTimeZoneOffset);
|
||||||
|
NewText := IntToStr(Timestamp)
|
||||||
|
end else
|
||||||
NewText := UnformatNumber(NewText);
|
NewText := UnformatNumber(NewText);
|
||||||
end;
|
end;
|
||||||
Results.SetCol(Column, NewText, False, FGridEditFunctionMode);
|
Results.SetCol(Column, NewText, False, FGridEditFunctionMode);
|
||||||
|
Reference in New Issue
Block a user