Delphi的DateTimeToUnix/UnixToDateTime转换时间并没有考虑到本地时间和格林尼治时间的差,结果我天朝时间被赤裸裸的差了8个小时.
type time_t = Int64; function DateTimeToUnix(ConvDate: TDateTime): time_t; var zi : TTimeZoneInformation; begin GetTimeZoneInformation(zi); Result := Round((ConvDate - UnixDateDelta) * 86400) + 60*(zi.Bias + zi.DaylightBias); end; function UnixToDateTime(USec: time_t): TDateTime; var zi : TTimeZoneInformation; begin GetTimeZoneInformation(zi); Result := ((USec - 60*zi.Bias) / 86400) + UnixDateDelta; end;