本文整理汇总了C++中CTimeSpan::GetTotalHours方法的典型用法代码示例。如果您正苦于以下问题:C++ CTimeSpan::GetTotalHours方法的具体用法?C++ CTimeSpan::GetTotalHours怎么用?C++ CTimeSpan::GetTotalHours使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTimeSpan
的用法示例。
在下文中一共展示了CTimeSpan::GetTotalHours方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TimeToFriendlyString
ATL::CString GlobeFuns::TimeToFriendlyString(const CTime &t)
{
CTimeSpan tmSpan = CTime::GetCurrentTime() - t;
CString strRet;
if (tmSpan.GetTotalMinutes()<1)
{
return "现在";
}
//if (tmSpan.GetTotalMinutes()<10)
//{
// strRet.Format("%d分钟前",tmSpan.GetTotalMinutes());
// return strRet;
//}
if (tmSpan.GetTotalMinutes()<60)
{
strRet.Format("%d分钟前",tmSpan.GetTotalMinutes());
return strRet;
}
if (tmSpan.GetTotalHours()<24)
{
strRet.Format("%d小时前",tmSpan.GetTotalHours());
return strRet;
}
strRet.Format("%d天前",tmSpan.GetTotalHours()/24);
return strRet;
}
示例2: 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() );
}
示例3: GetRunningTime
//此函数暂时不使用
CString CMainFrame::GetRunningTime()
{
CTimeSpan tSpan;
tSpan = CTime::GetCurrentTime() - m_StartTime;
LONGLONG totalSeconds = tSpan.GetTotalSeconds();
LONGLONG totalMinutes = tSpan.GetTotalMinutes();
LONGLONG totalHours = tSpan.GetTotalHours();
CString strRet="";
strRet.Format("%d天%02d时%02d分%02d秒",totalHours / 24,totalHours % 24,totalMinutes % 60,totalSeconds % 60);
return strRet;
}
示例4: FormatElapsed
string VirtualListCtrlFT::FormatElapsed(CTimeSpan &span)
{
string ret;
char buf[4096];
if(span.GetTotalHours()==0) // < hour
{
sprintf(buf,"%u:%02u",span.GetMinutes(),span.GetSeconds());
}
else // > hour
{
sprintf(buf,"%u:%02u:%02u",span.GetHours(),span.GetMinutes(),span.GetSeconds());
}
ret=buf;
return ret;
}
示例5: CheckAndTrigger
void Alarm::CheckAndTrigger()
{
if (ValidFieldFlags == 0)
return;
BOOL Triggered = TRUE;
CTime now = CTime::GetCurrentTime();
if ((ValidFieldFlags & VF_TIMEOFDAY) != 0)
{
if ((now.GetHour() != TimeOfDayHour) ||
(now.GetMinute() != TimeOfDayMinute))
{
Triggered = FALSE;
}
}
if ((ValidFieldFlags & VF_DAYOFWEEK) != 0)
{
if (now.GetDayOfWeek() != DayOfWeek)
Triggered = FALSE;
}
if ((ValidFieldFlags & VF_DAYOFMONTH) != 0)
{
if (now.GetDay() != DayOfMonth)
Triggered = FALSE;
}
if ((ValidFieldFlags & VF_MONTHOFYEAR) != 0)
{
if (now.GetMonth() != MonthOfYear)
Triggered = FALSE;
}
if (Triggered)
{
CTimeSpan timeSinceLastTrigger = now - TimeLastTriggered;
if ((ValidFieldFlags & VF_TIMEOFDAY) != 0)
{
if (timeSinceLastTrigger.GetTotalMinutes() < 2)
Triggered = FALSE;
}
else if (((ValidFieldFlags & VF_DAYOFWEEK) != 0) ||
((ValidFieldFlags & VF_DAYOFMONTH) != 0))
{
if (timeSinceLastTrigger.GetTotalHours() < 26)
Triggered = FALSE;
}
else
{
if (timeSinceLastTrigger.GetTotalHours() < (24*33))
Triggered = FALSE;
}
}
if (Triggered)
{
TimeLastTriggered = now;
TRACE1("TRIGGER: %s\n", TextMessage);
DAlarmNotify& dlg = *new DAlarmNotify;
dlg.TextMessage = TextMessage;
dlg.Create(IDD_ALARMNOTIFY);
dlg.ShowWindow(SW_SHOW);
sndPlaySound(((CAlarmsDlg*)theApp.m_pMainWnd)->alarmsSoundFile,SND_ASYNC);
}
}