本文整理汇总了C++中CTimeSpan类的典型用法代码示例。如果您正苦于以下问题:C++ CTimeSpan类的具体用法?C++ CTimeSpan怎么用?C++ CTimeSpan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CTimeSpan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KillTimer
void CProgressThreadDlg::SetFinished()
{
if (m_uTimerID != 0) {
KillTimer(m_uTimerID);
}
// update button
CWnd* pWnd = GetDlgItem(IDC_CANCEL);
ASSERT(pWnd);
pWnd->SetWindowText("OK");
char endTitle[80];
MakeString(endTitle, m_sCaption, " Completed", 80);
ChangeTitle(endTitle);
// progress bar to end
SetProgressStep(m_nSteps);
// final time label
pWnd = GetDlgItem(IDC_ELAPSED_TIME);
ASSERT(pWnd);
m_timeEnd = CTime::GetCurrentTime();
CTimeSpan ts = m_timeEnd - m_timeStart;
CString sText = ts.Format("Total elapsed time %H:%M:%S");
pWnd->SetWindowText(sText);
m_bOkToClose = true;
}
示例2: t1
void CCenterServerDlg::CheckBanBen()
{
return ;
CString sn ="20071030";////截止日期
long in=atol(sn.GetBuffer (sn.GetLength ()));
if(in<=0)return ;
int y1=atoi(sn.Mid (0,4)),
m1 =atoi(sn.Mid (4,2)),
d1=atoi(sn.Mid (6,2));
CTime t1(y1,m1,d1,0,0,0);
time_t ct;
time( &ct ) ;
CTime t2(ct);
CTimeSpan tsp;
tsp=t2-t1;//// 当前日期 - 截止日期
LONGLONG dd=tsp.GetDays ();
if(t2>t1)//dd > 0)
{
KillTimer(1);
KillTimer(2);
KillTimer(3);
m_CenterServerModule.StoptService();
AfxMessageBox("本软件生命周期到期,请重新联系www.bzw.cn获取升级版本。(此提示并非时间限制,而是说明程序寿命已到,获取升级版本是免费的。)");
CDialog::OnOK ();//theApp.m_pMainWnd->DestroyWindow ();
return ;
}
}
示例3:
void CMainFrame::OnTimer
(
UINT nIDEvent
)
{
CTimeSpan timeLeft = 0;
LONG minLeft = 0;
LONG secLeft = 0;
CMainFrame *hWnd = NULL;
char *szSubj = NULL;
log_printf("CMainFrame::OnTimer: entered.\n");
//#if 0 ///////////////////////////////////////////////////////
hWnd = (CMainFrame *)theApp.m_pMainWnd;
get_cert_time_left(szCertRealm, &timeLeft); // returns 0 if no realm or cert
minLeft = timeLeft.GetTotalMinutes();
// Set TrayIcon to reflect status of cert (if any)
if (minLeft >= CERT_DYING)
hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_AUTH);
else
{
if (minLeft < CERT_DYING)
{
szSubj = get_cert_subj(szCertRealm);
// If null Subject, then no cert exists so change to Un-authenticated Icon
if (!szSubj)
hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_UNAUTH);
else
{
// Alternate TrayIcons 'tween DEAD & DYING
secLeft = (int)timeLeft.GetTotalSeconds();
if ((secLeft % 2))
hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_DEAD);
else
hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_AUTH);
free(szSubj);
}
}
else
hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_DEAD);
log_printf("CMainFrame::OnTimer: gszHardErrorMsg=%s.\n", gszHardErrorMsg);
if (bkx509busy == FALSE)
{
bkx509busy = TRUE;
kx509_main(kx509_argc, kx509_argv);
bkx509busy = FALSE;
}
}
//#endif // 0 //////////////////////////////////////////////////////////////////
// Do above check every 5 seconds
(void)SetTimer(ID_SAMPLE_RATE, 5*1000, NULL);
CFrameWnd::OnTimer(nIDEvent);
}
示例4: UpdateElapsedTime
// 경과 시간 갱신
VOID CConsoleManager::UpdateElapsedTime( VOID )
{
CTime CurrentTime = CTime::GetCurrentTime();
LONGLONG dElapsedHour = 0;
CTimeSpan ElapsedTime;
// m_stOperationTime.StartTime와 CurrentTime 비교
if( m_stOperationTime.StartTime > CurrentTime )
{
g_Log.WriteLog( false,
LOG_CLASS_WARNING,
TEXT( "%s | Operation time value is invalid.\n" ),
TEXT( __FUNCTION__ ) );
m_stOperationTime.wElapsedHour = 0;
m_stOperationTime.wElapsedMinute = 0;
return;
}
ElapsedTime = CurrentTime - m_stOperationTime.StartTime;
// 경과 시 갱신
dElapsedHour = ElapsedTime.GetTotalHours();
if( 9999 < dElapsedHour ) // 365일 * 24시간 = 8760시간
m_stOperationTime.wElapsedHour = 9999;
else
m_stOperationTime.wElapsedHour = static_cast<WORD>( dElapsedHour );
// 경과 분 갱신
m_stOperationTime.wElapsedMinute = static_cast<WORD>( ElapsedTime.GetMinutes() );
}
示例5: YEAR
void CTortoiseProcApp::EnableCrashHandler()
{
// the crash handler is enabled by default, but we disable it
// after 3 months after a release
#define YEAR ((((__DATE__ [7] - '0') * 10 + (__DATE__ [8] - '0')) * 10 \
+ (__DATE__ [9] - '0')) * 10 + (__DATE__ [10] - '0'))
#define MONTH (__DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 1 : 6) \
: __DATE__ [2] == 'b' ? 2 \
: __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? 3 : 4) \
: __DATE__ [2] == 'y' ? 5 \
: __DATE__ [2] == 'l' ? 7 \
: __DATE__ [2] == 'g' ? 8 \
: __DATE__ [2] == 'p' ? 9 \
: __DATE__ [2] == 't' ? 10 \
: __DATE__ [2] == 'v' ? 11 : 12)
#define DAY ((__DATE__ [4] == ' ' ? 0 : __DATE__ [4] - '0') * 10 \
+ (__DATE__ [5] - '0'))
#define DATE_AS_INT (((YEAR - 2000) * 12 + MONTH) * 31 + DAY)
CTime compiletime(YEAR, MONTH, DAY, 0, 0, 0);
CTime now = CTime::GetCurrentTime();
CTimeSpan timediff = now-compiletime;
if (timediff.GetDays() > 3*31)
{
// crasher.Enable(FALSE);
}
}
示例6: OnTimer
void CBillingMgrJP::OnTimer( CAccount* pAccount )
{
if( pAccount->m_fCheck == m_iBillingFreePass ) // 무료사용자 skip
return;
CTime tm = 0;
if( pAccount->m_TimeOverDays == tm ) // login 미처리자 or timeover skip
return;
CTime cur = CTime::GetCurrentTime();
if( pAccount->m_TimeOverDays <= cur ) // timerover 처리
{
pAccount->m_TimeOverDays = 0;
g_dpSrvr.CloseExistingConnection( pAccount->m_lpszAccount, ERROR_BILLING_TIME_OVER );
}
else
{
// 남은 시간 통지
CTimeSpan ts = pAccount->m_TimeOverDays - cur;
if ( ts.GetTotalMinutes() >= 59 && ts.GetTotalMinutes() <= 61 &&
pAccount->m_nStatus != ACCOUNT_STATUS_NOTIFIED &&
pAccount->m_fRoute == TRUE )
{
pAccount->m_nStatus = ACCOUNT_STATUS_NOTIFIED;
g_dpDbSrvr.SendOneHourNotify( pAccount ); // TRANS에 보낸다.
}
}
}
示例7: TRACE0
LRESULT
CPDImfcDlg::OnDataStopped( WPARAM wP, LPARAM lP )
{
TRACE0("CPDImfcDlg::OnDataStopped\n");
CString msg;
CTimeSpan ts = m_timeStop - m_timeStart;
CString s = ts.Format("%M:%S");
msg.Format(_T("WM_PI_DATA_STOPPED: time elapsed %s, %d frames collected, %d bytes, %d frames dropped, %d frames displayed\r\n"),
(LPCTSTR)s, m_dwContFrameCount, m_dwContSize, m_dwOverflowCount, m_dwFramesDisplayed);
AddMsg(msg);
if (m_bCapture)
{
ParseFrame( g_pMotionBuf, m_dwContSize, TRUE );
}
if (m_bStyPno)
{
ClearStyMode();
}
m_bCont = FALSE;
m_bStyPno = FALSE;
m_bCapture = FALSE;
EnableButtons();
UpdateData(FALSE);
return 0;
}
示例8: BuildWWhizReg
void BuildWWhizReg(WWhizReg* reg)
{
CString str;
CTime firstTime = GetFirstTime();
CTime curTime = CTime::GetCurrentTime();
CTimeSpan timeDiff = curTime - firstTime;
CTimeSpan time21Days(21, 0, 0, 0);
if (firstTime + time21Days > curTime)
{
}
// Read the key stuff from the registry.
// validRegistration = ValidRegistration();
// if (!HasExpiredHelper() && !validRegistration && timeDiff.GetDays() > 14)
CString regName = AfxGetApp()->GetProfileString("Config", "RegName");
CString regCode = AfxGetApp()->GetProfileString("Config", "RegCode");
time_t registrationTime;
bool decoded = ValidateRegistrationCode(regCode, regName, registrationTime);
if (!HasExpiredHelper() && !decoded && timeDiff.GetDays() > 14)
{
CExpiredDlg dlg;
dlg.m_numDays = timeDiff.GetDays() + 1;
dlg.DoModal();
}
}
示例9: UpdateTradeExtended
void CSpaceObject::UpdateTradeExtended (const CTimeSpan &ExtraTime)
// UpdateTradeExtended
//
// Update trade after a long time.
{
// Refresh inventory, if necessary
CTradingDesc *pTradeOverride = GetTradeDescOverride();
CDesignType *pType = GetType();
CTradingDesc *pTrade = (pType ? pType->GetTradingDesc() : NULL);
if ((pTrade || pTradeOverride) && ExtraTime.Days() > 0 && !IsAbandoned())
{
// Compute the percent of the inventory that need to refresh
int iRefreshPercent;
if (ExtraTime.Days() >= DAYS_TO_REFRESH_INVENTORY)
iRefreshPercent = 100;
else
iRefreshPercent = 100 * ExtraTime.Days() / DAYS_TO_REFRESH_INVENTORY;
// Do it
if (pTradeOverride)
pTradeOverride->RefreshInventory(this, iRefreshPercent);
if (pTrade)
pTrade->RefreshInventory(this, iRefreshPercent);
}
}
示例10: UpdatePossible
void CDialogMistakes::UpdatePossible(){
m_dTotalPossible = CBjDlg::m_dTotalPossible;
m_dTotalPossible2 = CBjDlg::m_dTotalPossible;
//add history
if (m_pCurrentHistory){
m_dTotalPossible += m_pCurrentHistory->m_dTotalPossible;
m_dTotalPossible2 += m_pCurrentHistory->m_dTotalPossible2;
}
m_dTotalActual = m_dTotalPossible - m_dTotalMistakes;
m_dTotalActual2 = m_dTotalPossible2 - m_dTotalMistakes2;
//update the other stats as well
m_nHandsPlayed = CBjDlg::m_nHandsPlayed;
//add history
if (m_pCurrentHistory){
m_nHandsPlayed += m_pCurrentHistory->m_nHandsPlayed;
}
m_dWinPerHand = m_dTotalActual/m_nHandsPlayed;
m_dAvgStandardCount = CBjDlg::m_dAvgStandardCount;
m_nActualWin = m_pBjDlg->m_DlgPractice.m_nSessionMoney;
m_dTheoreticalWin = m_dWinPerHand*m_nHandsPlayed*m_pBjDlg->m_nLowBet;
//add history
CTimeSpan total = CBjDlg::m_TotalPlayTime;
if (m_pCurrentHistory){
m_dAvgStandardCount = (m_dAvgStandardCount*CBjDlg::m_nHandsPlayed + m_pCurrentHistory->m_dAvgStandardCount*m_pCurrentHistory->m_nHandsPlayed);
m_dAvgStandardCount /= m_nHandsPlayed;
total += m_pCurrentHistory->m_TimePlayed;
m_nActualWin += m_pCurrentHistory->m_nRealWin;
}
m_strTimePlayed = total.Format("%D days %H:%M");
//add history
UpdateData(FALSE);
}
示例11: DelOldLog
//
// 機能 : 古いログの削除
//
// 機能説明 : LOG_EXPIRE 日以上前のログは削除
//
// 返り値 : true 正常終了
// false エラー発生
//
// 備考 :
//
bool CTPerror::DelOldLog()
{
CString str;
CFileFind finder;
CTime ntm;
CTime tm;
CTimeSpan tms;
CFileSpec fs;
/// LOG_EXPIRE期間以前のログファイルを削除
if (!SetCurrentDirectory(LogDir)) return false;
ntm = CTime::GetCurrentTime();
BOOL bWorking = finder.FindFile(_T("*.log"));
if (!bWorking) return false;
str.Empty();
while (bWorking)
{
bWorking = finder.FindNextFile();
if (!finder.IsDirectory()) {
str = finder.GetFileName();
/// ログファイル作成日付と現在との差分
finder.GetCreationTime(tm);
tms = ntm - tm;
if (tms.GetDays() > LOG_EXPIRE) {
fs.SetFullSpec(str);
if (!fs.Exist()) continue;
fs.FileDelete();
}
}
}
finder.Close();
return true;
}
示例12:
CString CTradeStatistic2::CalculateElapseTime()
{
CString strElapsedTime;
CTime tmNow = CTime::GetCurrentTime();
CTimeSpan tElapsed = tmNow - m_tmBegin;
strElapsedTime.Format("%d小时 %d分钟 %d秒", tElapsed.GetHours(), tElapsed.GetMinutes(), tElapsed.GetSeconds());
return strElapsedTime;
}
示例13: while
/*********************************************************
函数名称:CheckSocketStatus
功能描述:检查每个Socket 将其中空的和超时的删除掉
创建时间:2016-08-19
参数说明:
返 回 值:
*********************************************************/
int CSocketServerDlg::CheckSocketStatus(void)
{
POSITION pos = m_listSocketChat.GetHeadPosition();
while(pos != NULL)
{
CChatSocket* p = m_listSocketChat.GetNext(pos);
// 删除空Socket
if(p == NULL)
{
if(pos == NULL)
{// 空Socket位于链表末尾
m_listSocketChat.RemoveTail();
break;
}
else
{
POSITION posTemp = pos;
m_listSocketChat.GetPrev(posTemp);
m_listSocketChat.RemoveAt(posTemp);
}
continue;
}
// 删除超过时间没有通信的Socket
int nMaxSec = 30; // 等待的最大时间
CTimeSpan tmsp;
tmsp = CTime::GetCurrentTime() - p->m_tmLastMsg;
TRACE("%d\n", tmsp.GetTotalSeconds());
if(tmsp.GetTotalSeconds() >= nMaxSec || tmsp.GetSeconds() < 0)
{
CString csOutMsg;
CString csID;
csID = p->m_userID;
csOutMsg.Format(_T("用户%s连接超时"), csID);
OutputInfo(csOutMsg);
m_data.SetUserStatus(p->m_userID, IDS_STATUS_OFFLINE);
p->Close(); // 关闭连接
delete p; // 释放内存
// 删除元素
if(pos == NULL)
{// 空Socket位于链表末尾
m_listSocketChat.RemoveTail();
break;
}
else
{
POSITION posTemp = pos;
m_listSocketChat.GetPrev(posTemp);
m_listSocketChat.RemoveAt(posTemp);
}
continue;
}
}
return 0;
}
示例14: OnTimer
void CChatDlg::OnTimer(UINT nIDEvent)
{
if (nIDEvent == IDT_TOTAL_TIME) {
CTime now = CTime::GetCurrentTime();
CTimeSpan span = now - startTime;
SetDlgItemText(IDC_TOTAL_TIME, span.Format("%H:%M:%S"));
} else
CDialog::OnTimer(nIDEvent);
}
示例15: setTimer
static void setTimer(CTime &t)
{
CTime cur = CTime::GetCurrentTime();
if (t >= cur) {
KillTimer(NULL, timerID);
CTimeSpan span = t - cur;
timerID = SetTimer(NULL, 0, span.GetTotalSeconds() * 1000, onTimer);
}
}