(2011-10-24 10:11:42)作者:中天數(shù)字 COleDateTime,、CTime--->CString
方法1:COleDateTime::ParseDateTime() CString strDate = _T("1987-06-21"); COleDateTime oleDate; oleDate.ParseDateTime(strDate, VAR_DATEVALUEONLY); 方法2:COleVariant CString strDate = _T("1987-06-21"); COleVariant varTime(strDate); varTime.ChangeType(VT_DATE); COleDateTime oleDate(varTime); //COleDateTime oleDate; //oleDate=varTime; COleDateTime--->CTime: 方法1:用COleDateTime::GetAsSystemTime(SYSTEMTIME& sysTime) COleDateTime oleDate(1987, 6, 21, 0, 0, 0); SYSTEMTIME sysTime; oleDate.GetAsSystemTime(sysTime); CTime tm(sysTime); 方法2:用VariantTimeToSystemTime函數(shù) COleDateTime oleDate(1987, 6, 21, 0, 0, 0); SYSTEMTIME sysTime; VariantTimeToSystemTime(oleDate, &sysTime); CTime tm(sysTime);
方法1:用CTime::GetTime()得到time_t CTime time(1987, 6, 21, 0, 0, 0); time_t tm = time.GetTime(); COleDateTime oleTime(tm); 方法2:用COleDateTime::GetAsSystemTime(SYSTEMTIME& sysTime) CTime time(1987, 6, 21, 0, 0, 0); SYSTEMTIME sysTime; time.GetAsSystemTime(sysTime); COleDateTime oleTime(sysTime); //COleDateTime oleTime; //oleTime=sysTime; |
|