background image

已解决这问题了。

Delphi 和 语言时间的转换

1899-12-30 到 1970-1-1 之间相隔 25569 天,知道这个转换就简单了

//C 语言时间:int32 格式,1970-1-1 00:00:00 为起点秒数
//Delphi 时间:Double 格式,1899-12-30 00:00:00 为起点天数
//2.75: 1900-1-1 18:00
function CTimeToTime(t: LongInt): TDateTime;
begin
  Result := t / 86400 + 25569;
end;

function TimeToCTime(t: TDateTime): LongInt;
begin
  Result := Round((t - 25569) * 86400);
end;

Delphi 

 

和 DOS 文件时间的转换

Delphi 中提供了现成的转换函数
//DOS 文件时间转换为 Delphi 时间
function FileDateToDateTime(FileDate: Integer): TDateTime;

//Delphi 时间转换为 DOS 文件时间
function DateTimeToFileDate(DateTime: TDateTime): Integer;