void CPlayBackByTime::OnOK() { DeviceNode *pInfo; SYSTEMTIME systime; NET_TIME stime, etime; if(!UpdateData(true)) { return; } if(m_devicesel.GetCount() <= 0 || m_devicesel.GetCurSel() < 0) { MessageBox(ConvertString(MSG_SCHRECORD_NODEVICE), ConvertString(MSG_SCHRECORD_CHOOSEDEVICE)); return; } if(m_channelsel <= 0 || m_channelsel > MAX_CHANNUM) { MessageBox(ConvertString(MSG_SCHRECORD_CHLNO_INVALID), ConvertString(MSG_SCHRECORD_CHLNO)); return; } /*Begin: Add by yehao(10857) For Check error 2006-12-27*/ /*if (m_startdate >= m_enddate) { MessageBox(MSG_SCHRECORD_TIMEINPUT_ERR,MSG_SCHRECORD_TIMEINPUT); return; }*/ /*End: yehao(10857) Check error */ CTime time = CTime(m_startdate.GetYear(),m_startdate.GetMonth(),m_startdate.GetDay(), m_starttime.GetHour(), m_starttime.GetMinute(), m_starttime.GetSecond()); if(!time.GetAsSystemTime(systime) || !time.GetAsSystemTime(systime)) { MessageBox(ConvertString(MSG_SCHRECORD_TIMEINPUT_ERR), ConvertString(MSG_SCHRECORD_TIMEINPUT)); return; } g_SysTimetoYwtime(&systime,&stime); time = CTime(m_enddate.GetYear(),m_enddate.GetMonth(),m_enddate.GetDay(), m_endtime.GetHour(), m_endtime.GetMinute(), m_endtime.GetSecond()); if(!time.GetAsSystemTime(systime) || !time.GetAsSystemTime(systime)) { MessageBox(ConvertString(MSG_SCHRECORD_TIMEINPUT_ERR), ConvertString(MSG_SCHRECORD_TIMEINPUT)); return; } g_SysTimetoYwtime(&systime,&etime); pInfo = (DeviceNode *)m_devicesel.GetItemData(m_devicesel.GetCurSel()); m_playbackinfo.pDevice = pInfo; m_playbackinfo.nChannel = m_channelsel - 1; m_playbackinfo.starttime = stime; m_playbackinfo.endtime = etime; CDialog::OnOK(); }
void CScheduledTask::SetStartDateTime ( const CTime& time ) { time.GetAsSystemTime ( m_timeStart ); m_timeStart.wSecond = 0; m_timeStart.wMilliseconds = 0; }
/** * 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; }
BOOL CMonthCalCtrl::SetSelRange(const CTime& refMinRange, const CTime& refMaxRange) { // control must have multiple select ASSERT((GetStyle() & MCS_MULTISELECT)); ASSERT(::IsWindow(m_hWnd)); SYSTEMTIME sysTimes[2]; BOOL bResult = FALSE; if (refMinRange.GetAsSystemTime(sysTimes[0]) && refMaxRange.GetAsSystemTime(sysTimes[1])) { bResult = (BOOL) ::SendMessage(m_hWnd, MCM_SETSELRANGE, 0, (LPARAM)sysTimes); } return bResult; }
bool CFileBrowserListCtrl::FormatTime(CTime Time, CString& Str) { static const int MAX_STRING = 64; // maximum date or time string SYSTEMTIME st; Time.GetAsSystemTime(st); TCHAR DateStr[MAX_STRING], TimeStr[MAX_STRING]; if (!GetDateFormat(0, 0, &st, NULL, DateStr, MAX_STRING)) return(FALSE); if (!GetTimeFormat(0, TIME_NOSECONDS, &st, NULL, TimeStr, MAX_STRING)) return(FALSE); Str = CString(DateStr) + " " + TimeStr; return(TRUE); }
BOOL CMonthCalCtrl::SetCurSel(const CTime& refTime) { ASSERT(::IsWindow(m_hWnd)); SYSTEMTIME sysTime; BOOL bRetVal = FALSE; if (refTime.GetAsSystemTime(sysTime)) { bRetVal = (BOOL) ::SendMessage(m_hWnd, MCM_SETCURSEL, 0, (LPARAM) &sysTime); } return bRetVal; }
/** * FUNCTION : FormatDateAndTime * DESCRIPTION : Generates a displayable string from a CTime object in * system short or long format or as a relative value * cTime - the time * option - DATE_SHORTDATE or DATE_LONGDATE * bIncluedeTime - whether to show time as well as date * bRelative - if true then relative time is shown if reasonable * If HKCU\Software\TortoiseGit\UseSystemLocaleForDates is 0 then use fixed format * rather than locale * RETURN : CString containing date/time */ CString CAppUtils::FormatDateAndTime( const CTime& cTime, DWORD option, bool bIncludeTime /*=true*/, bool bRelative /*=false*/) { CString datetime; if ( bRelative ) { datetime = ToRelativeTimeString( cTime ); } else { // should we use the locale settings for formatting the date/time? if (CRegDWORD(_T("Software\\TortoiseGit\\UseSystemLocaleForDates"), TRUE)) { // yes SYSTEMTIME sysTime; cTime.GetAsSystemTime( sysTime ); TCHAR buf[100]; GetDateFormat(LOCALE_USER_DEFAULT, option, &sysTime, NULL, buf, _countof(buf) - 1); datetime = buf; if ( bIncludeTime ) { datetime += _T(" "); GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysTime, NULL, buf, _countof(buf) - 1); datetime += buf; } } else { // no, so fixed format if ( bIncludeTime ) { datetime = cTime.Format(_T("%Y-%m-%d %H:%M:%S")); } else { datetime = cTime.Format(_T("%Y-%m-%d")); } } } return datetime; }