Certainly.
The constructor code:
Code:
CTime::CTime(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, int nDST)
{
struct tm atm;
atm.tm_sec = nSec;
atm.tm_min = nMin;
atm.tm_hour = nHour;
ASSERT(nDay >= 1 && nDay <= 31);
atm.tm_mday = nDay;
ASSERT(nMonth >= 1 && nMonth <= 12);
atm.tm_mon = nMonth -1; // tm_mon is 0 based
ASSERT(nYear >= 1900);
atm.tm_year = nYear - 1900; //tm_year is 1900 based
atm.tm_isdst = nDST;
m_time = mktime(&atm);
ASSERT(m_time != -1); //This assertion fails
}
The above is called from the following other CTime constructor:
Code:
CTime::CTime(const SYSTEMTIME& sysTime, int nDST)
{
if(sysTime.wYear < 1900)
{
time_t time0 = 0L;
CTime timeT(time0);
*this = timeT;
}
else
{
//This next line calls the constructor with failed assertion
CTime timeT( (int)sysTime.wYear, (int)sysTime.wMonth, (int)sysTime.wDay, (int)sysTime.wHour, (int)sysTime.wMinute, (int)sysTime.wSecond, nDST);
*this = timeT;
}
}
which in turn is called by
Code:
DWORD CDateTimeCtrl::GetTime(CTime& timeDest) const
{
SYSTEMTIME sysTime;
DWORD dwResult = (DWORD)
::SendMessage(m_hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM) &sysTime);
if (dwResult == GDT_VALID)
timeDest = CTime(sysTime); //Execution flow goes through here
return dwResult;
}
Note that all of the above is stock MFC code; the only thing I do is call UpdateData(), which calls DoDataExchange, which calls the above.