使用COleDateTime类的<操作符问题。
程序如下(片断):
else if (CurrentTime < CurrentPageBeginTime)
{
CDC* pDC = GetDC();
CString str;
str.Format("%d-%d-%d %d:%d%d %d-%d-%d %d:%d%d",
CurrentTime.GetYear(), CurrentTime.GetMonth(), CurrentTime.GetDay(),
CurrentTime.GetHour(), CurrentTime.GetMinute(), CurrentTime.GetSecond(),
CurrentPageBeginTime.GetYear(), CurrentPageBeginTime.GetMonth(), CurrentPageBeginTime.GetDay(),
CurrentPageBeginTime.GetHour(), CurrentPageBeginTime.GetMinute(), CurrentPageBeginTime.GetSecond());
pDC->TextOut(100, 0, str);
ReleaseDC(pDC);
}
上面的程序结果大家一定不相信,打印出来的时间完全相等!我想可能是两个类在毫秒级上不相等,于是改程序如下:
SYSTEMTIME t1, t2;
CurrentTime.GetAsSystemTime(t1);
CurrentPageBeginTime.GetAsSystemTime(t2);
str.Format("%d %d", t1.wMilliseconds, t2.wMilliseconds);
结果打印出来也完全相等,请问为什么?我一定要作时间的比较!