function DateTimeToCTime(t : TDateTime) : Longint;
function GetGMTBias: Integer;
var
info : TTimeZoneInformation;
Mode: DWord;
begin
Mode := GetTimeZoneInformation(info);
result := info.Bias;
case Mode of
TIME_ZONE_ID_STANDARD: result := result + info.StandardBias;
TIME_ZONE_ID_DAYLIGHT: result := result + info.DaylightBias;
end;
end;
function LocaleToGMT(const Value: TDateTime): TDateTime;
begin
result := Value + (GetGMTBias / MinsPerDay);
end;
begin
//(t-36526)*24*3600 肯定是整数
Result := Ceil(946656000 + (LocaleToGMT(t) - 36526) * 24 * 3600)
+ 57600;
end;
function CTimeToDateTime(ct : Longint) : TDateTime;
const
cDeltaDate : Integer = 25569; // 1970/01/01
cSecPerMint : Integer = 60;
cSecPerHour : Integer = (60*60);
cSecPerDay : Integer = (60*60*24);
var
hh, mm, ss : Word;
n : Integer;
begin
{// GMT=+8,格林时间+8时区(北京)}
//ct := ct - cSecPerHour * 8;
n := ct mod cSecPerDay;
hh := n div cSecPerHour;
n := n mod cSecPerHour;
mm := n div cSecPerMint;
ss := n mod cSecPerMint;
Result := (ct div cSecPerDay) + cDeltaDate + EncodeTime(hh, mm, ss, 0);
end;