我正在使用CodeSite。在原始日志文件中,我看到下面的TimeStamp格式--如何将它转换为实际的DateTime?这是什么TimeStamp格式?这不是Epoch TimeStamp格式。
到目前为止,我正试图转换到TimeStamp下面。
TimeStamp=736843.29124842
这应该转换为5/29/2018 8:05:24.842 (MST)。
发布于 2018-06-02 13:59:39
你不应该自己解析那些文件。但是,如果需要,下面是解析CodeSite消息时间戳的函数(基于CodeSite方法时间戳解析代码,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内部实现,可能会发生更改。
https://stackoverflow.com/questions/50649851
复制相似问题