CTime::CTime(const SYSTEMTIME& sysTime) { if (sysTime.wYear < 1900) { time_t time0 = 0L; CTime timeT(time0); *this = timeT; } else { CTime timeT( (int)sysTime.wYear, (int)sysTime.wMonth, (int)sysTime.wDay, (int)sysTime.wHour, (int)sysTime.wMinute, (int)sysTime.wSecond); *this = timeT; } }
CMSTime::CMSTime(const SYSTEMTIME& sysTime, int nDST) { if (sysTime.wYear < 1900) { __time64_t time0 = 0L; CMSTime timeT(time0); *this = timeT; } else { CMSTime timeT( (int)sysTime.wYear, (int)sysTime.wMonth, (int)sysTime.wDay, (int)sysTime.wHour, (int)sysTime.wMinute, (int)sysTime.wSecond, nDST); *this = timeT; } }
CTime::CTime(const FILETIME& fileTime) { // first convert file time (UTC time) to local time FILETIME localTime; VERIFY(FileTimeToLocalFileTime(&fileTime, &localTime)); // then convert that time to system time SYSTEMTIME sysTime; VERIFY(FileTimeToSystemTime(&localTime, &sysTime)); // then convert the system time to a time_t (C-runtime local time) CTime timeT(sysTime); *this = timeT; }
CTime::CTime(const FILETIME& fileTime, int nDST) { // first convert file time (UTC time) to local time FILETIME localTime; if (!FileTimeToLocalFileTime(&fileTime, &localTime)) { m_time = 0; return; } // then convert that time to system time SYSTEMTIME sysTime; if (!FileTimeToSystemTime(&localTime, &sysTime)) { m_time = 0; return; } // then convert the system time to a time_t (C-runtime local time) CTime timeT(sysTime, nDST); *this = timeT; }