CodeSite TimeStamp to DateTime

1.9k Views Asked by At

I am using CodeSite. In the raw log files, i see below TimeStamp format -- how do i convert this to Actual DateTime? What TimeStamp format is this? This is not Epoch TimeStamp format.

I am trying to convert below TimeStamp to Date.

TimeStamp=736843.29124842

This should convert to 5/29/2018 8:05:24.842 (MST).

1

There are 1 best solutions below

1
Victoria On BEST ANSWER

You're not supposed to parse those files by yourself. But well, if you want, here's the function which parses the CodeSite message timestamp (based on the TCodeSiteMessage.SetAsString method timestamp parsing code, CodeSite version 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;

Of course this is a CodeSite internal implementation and may be subject to change.