//判断两个CS类型的时间变量,返回值0 代表相等 1代表first时间大 2代表last时间大 int sCheckDataTime(CString csFirstTime,CString csLastTIme) { int nYear, nMonth, nDate, nHour, nMin, nSec; char cTime[50]={0}; WCharToMByte(csFirstTime,cTime,50); sscanf(cTime, "%d-%d-%d %d:%d:%d", &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec); CTime tFirstTime(nYear, nMonth, nDate, nHour, nMin, nSec);
memset(cTime,0,sizeof(cTime)); WCharToMByte(csLastTIme,cTime,50); sscanf(cTime, "%d-%d-%d %d:%d:%d", &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec); CTime tLastTime(nYear, nMonth, nDate, nHour, nMin, nSec); if(tFirstTime == tLastTime) { return 0; } else if(tFirstTime > tLastTime) { return 1; } else { return 2; } /*CTimeSpan tSpan=tCurTime-tStartTime; if (tSpan.GetTotalSeconds()<2)*/ }
BOOL CRecordDlg::WCharToMByte(LPCWSTR lpcwszStr, LPSTR lpszStr, DWORD dwSize) { DWORD dwMinSize; dwMinSize = WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,NULL,0,NULL,FALSE); if(dwSize+1 < dwMinSize) { return FALSE; } WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,lpszStr,dwSize,NULL,FALSE); return TRUE; }