CodeSite TimeStamp到DateTime

时间:2018-06-01 19:20:07

标签: datetime delphi timestamp codesite

我正在使用CodeSite。在原始日志文件中,我看到下面的TimeStamp格式 - 我如何将其转换为实际日期时间?这是什么TimeStamp格式? 这不是Epoch TimeStamp格式。

我正在尝试将TimeStamp转换为Date。

时间戳= 736843.29124842

这应转换为5/29/2018 8:05:24.842(MST)。

1 个答案:

答案 0 :(得分:1)

你不应该自己解析这些文件。但是,如果你愿意,这里是解析CodeSite消息时间戳的函数(基于 TCodeSiteMessage.SetAsString 方法时间戳解析代码,CodeSite版本5.3.2):

function CodeSiteTimeStampToDateTime(const Value: string): TDateTime;
var
  P: Integer;
  T: TTimeStamp;
begin
  P := Pos('.', Value);
  if (P > 0) and TryStrToInt(Copy(Value, 1, P - 1), T.Date) and TryStrToInt(Copy(Value, P + 1, 20), T.Time) then
    Result := TimeStampToDateTime(T)
  else
    raise Exception.Create('Invalid timestamp value.');
end;

当然这是CodeSite的内部实施,可能会有所变化。