Charles Cruden
November 13th, 2000, 04:02 AM
I couldn't find this one mentioned here or anywhere on the MS support pages, so....
As is, CTime::CTime(const FILETIME &) incorrectly converts the FILETIME from UTC to local time when constructing the CTime object. (This is with MFC 4.2 / VC++ 6 SP 4.) Inspecting the code in TIMECORE.CPP will verify this, as will this code. Time1 and Time2 should be equal at the end, but one will be off by as many hours as the computer is away from UTC.
FILETIME ft;
SYSTEMTIME Time1, Time2;
GetSystemTimeAsFileTime(&ft);
CTime t(ft);
t.GetAsSystemTime(Time1);
FileTimeToSystemTime(&ft, &Time2);
As is, CTime::CTime(const FILETIME &) incorrectly converts the FILETIME from UTC to local time when constructing the CTime object. (This is with MFC 4.2 / VC++ 6 SP 4.) Inspecting the code in TIMECORE.CPP will verify this, as will this code. Time1 and Time2 should be equal at the end, but one will be off by as many hours as the computer is away from UTC.
FILETIME ft;
SYSTEMTIME Time1, Time2;
GetSystemTimeAsFileTime(&ft);
CTime t(ft);
t.GetAsSystemTime(Time1);
FileTimeToSystemTime(&ft, &Time2);