/** * Converts a given time to a relative display string (relative to current time) * Given time must be in local timezone */ CString CLoglistUtils::ToRelativeTimeString(CTime time) { // convert to COleDateTime SYSTEMTIME sysTime; time.GetAsSystemTime(sysTime); COleDateTime oleTime(sysTime); return ToRelativeTimeString(oleTime, COleDateTime::GetCurrentTime()); }
/** * Converts a given time to a relative display string (relative to current time) * Given time must be in local timezone */ CString CAppUtils::ToRelativeTimeString(CTime time) { CString answer; // convert to COleDateTime SYSTEMTIME sysTime; time.GetAsSystemTime( sysTime ); COleDateTime oleTime( sysTime ); answer = ToRelativeTimeString(oleTime, COleDateTime::GetCurrentTime()); return answer; }
int CValue::FromDate(int &nYear,int &nMonth,int &nDay,int &DayOfWeek,int &DayOfYear, int &WeekOfYear)const { int nCurDate=GetDate(); DateFromIntToYMD(nCurDate,nYear,nMonth,nDay); WeekOfYear=DayOfWeek=DayOfYear=0; if(nCurDate>DATE_DELTA) { COleDateTime oleTime(nYear, nMonth, nDay, 0, 0, 0); DayOfYear=oleTime.GetDayOfYear(); DayOfWeek=oleTime.GetDayOfWeek()-1; if(DayOfWeek<1) DayOfWeek=7; WeekOfYear=1+(DayOfYear-1)/7; int nD=(1+(DayOfYear-1)%7); if(nD>DayOfWeek) WeekOfYear++; } return nCurDate; }
void CValueControl::SetString(CString csParam) { if(!pWnd) return;//SetError("Не определен указатель на объект диалога"); CRuntimeClass* prt = pWnd->GetRuntimeClass(); CString csName=prt->m_lpszClassName; if(csName=="CButton") { CButton *pObj=(CButton *)pWnd; int nValue=atoi(csParam); if(nValue) pObj->SetCheck(true); else pObj->SetCheck(false); } else if(csName=="CComboBox") { SetError("Данному типу переменной нельзя присвоить значение"); /* CComboBox *pObj=(CComboBox *)pWnd; int nCurrentLine=pObj->FindString(-1,csStr); if(nCurrentLine<0) nCurrentLine=0; pObj->SetCurSel(nCurrentLine); pObj->GetLBText(nCurrentLine,csStr); */ } else if(csName=="CEdit"||csName=="CDropEdit"||csName=="CCalcEdit") { CEdit *pObj=(CEdit *)pWnd; csParam.Replace("\n","\r\n"); pObj->SetWindowText(csParam); } else if(csName=="CStatic") { CStatic *pObj=(CStatic *)pWnd; pObj->SetWindowText(csParam); // COXStaticText *pObj=(COXStaticText *)pWnd; // pObj->SetWindowText(csParam,1); } else if(csName=="CGroup") { CButton *pObj=(CButton *)pWnd; pObj->SetWindowText(csParam); } else if(csName=="CListBox") { SetError("Данному типу переменной нельзя присвоить значение"); } else if(csName=="CDateTimeCtrl") { if(!csParam.IsEmpty()) { CDateTimeCtrl *pObj=(CDateTimeCtrl *)pWnd; int nYear; int nMonth; int nDay; Date(csParam,nYear,nMonth,nDay); // set with a COleDateTime object COleDateTime oleTime(nYear, nMonth, nDay, 0, 0, 0); //if(timeNew.GetStatus() != COleDateTime::invalid); pObj->SetTime(oleTime); } } else if(csName=="CRadio") { CButton *pObj=(CButton *)pWnd; int nValue=atoi(csParam); HWND hParent=GetParent(pObj->m_hWnd); if(hParent) { int n1=pObj->GetDlgCtrlID(); int n2=n1; //определяем n2 for(int nID=n1+1; nID<n1+MAX_RADIO; nID++) { CWnd* pWnd=CWnd::FromHandle(hParent)->GetDlgItem(nID); if(!pWnd) break; CRuntimeClass* prt = pWnd->GetRuntimeClass(); if(prt->m_lpszClassName!="CRadio") break; if((1<<17)&pWnd->GetStyle()) break; n2=nID; } CWnd::FromHandle(hParent)->CheckRadioButton(n1,n2,n1+nValue-1); } } else if(csName=="CProgressCtrl") { CProgressCtrl *pObj=(CProgressCtrl *)pWnd; pObj->SetPos(atoi(csParam)); } else if(csName=="CSliderCtrl") { CSliderCtrl *pObj=(CSliderCtrl *)pWnd; pObj->SetPos(atoi(csParam)); } else ((CWnd*)pWnd)->SetWindowText(csParam); }