"Chris" <bo****@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello,
How can i convert a C++ CTime (4 bytes) into a C# DateTime ?
(my CTime is read in a file).
I beleive that CTime has the same storage representation as time_t, which is
a 64 bit integer representing the number of seconds since January 1, 1970
UDT. Marshall it as an Int64, and do the date arithmetic yourself.
Something like
static DateTime CTimeToDate(Int64 CTime)
{
TimeSpan span = TimeSpan.FromTicks(CTime*TimeSpan.TicksPerSecond);
DateTime t = new DateTime(1970,1,1).Add(span);
return TimeZone.CurrentTimeZone.ToLocalTime(t);
}
David