CodeSite TimeStamp到DateTime

问题描述 投票:0回答:1

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

我想在TimeStamp下面转换为Date。

时间戳= 736843.29124842

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

datetime delphi timestamp codesite
1个回答
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的内部实现,可能会有所变化。

© www.soinside.com 2019 - 2024. All rights reserved.