本文整理汇总了C++中COleDateTimeSpan::SetDateTimeSpan方法的典型用法代码示例。如果您正苦于以下问题:C++ COleDateTimeSpan::SetDateTimeSpan方法的具体用法?C++ COleDateTimeSpan::SetDateTimeSpan怎么用?C++ COleDateTimeSpan::SetDateTimeSpan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COleDateTimeSpan
的用法示例。
在下文中一共展示了COleDateTimeSpan::SetDateTimeSpan方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNextTickValue
double CChartAxis::GetNextTickValue(double Previous)
{
double NewTick = 0;
switch (m_AxisType)
{
case atStandard:
NewTick = Previous + m_TickIncrement;
break;
case atLogarithmic:
NewTick = Previous * m_TickIncrement;
break;
case atDateTime:
{
COleDateTime dtTick((DATE)Previous);
COleDateTimeSpan dtSpan;
switch (m_BaseInterval)
{
case tiSecond:
dtSpan.SetDateTimeSpan(0,0,0,m_iDTTickIntervalMult);
dtTick += dtSpan;
break;
case tiMinute:
dtSpan.SetDateTimeSpan(0,0,m_iDTTickIntervalMult,0);
dtTick += dtSpan;
break;
case tiHour:
dtSpan.SetDateTimeSpan(0,m_iDTTickIntervalMult,0,0);
dtTick += dtSpan;
break;
case tiDay:
dtSpan.SetDateTimeSpan(m_iDTTickIntervalMult,0,0,0);
dtTick += dtSpan;
break;
case tiMonth:
{
dtTick = AddMonthToDate(dtTick,m_iDTTickIntervalMult);
}
break;
case tiYear:
break;
}
NewTick = (DATE)dtTick;
}
break;
}
return NewTick;
}
示例2: ActivityCallback
static void __stdcall ActivityCallback(ConversionActivity* activity, void* userData)
{
COleDateTimeSpan ts;
ts.SetDateTimeSpan(0, 0, 0, activity->ElapsedTimeSpanInSeconds);
char spinner[] = {'-', '\\', '|', '/'};
if (_spinnerIndex++ >= 3) _spinnerIndex = 0;
TCHAR output1[128];
TCHAR output2[128];
TCHAR output3[128];
_stprintf_s(output1, _T(" %c %s converted: %sK d/l'ed:"),
spinner[_spinnerIndex],
ts.Format(_T("%H:%M:%S")),
CommaSeparate((ULONGLONG)activity->CurrentFileSize / 1024));
_stprintf_s(output2, _T("%sK"),
CommaSeparate((ULONGLONG)activity->DownloadCurrent / 1024));
_stprintf_s(output3, _T("/ %sK"),
CommaSeparate((ULONGLONG)activity->DownloadTotal / 1024));
_tprintf_s(_T("%s %s %s\r"), output1, output2, output3);
}
示例3: GetNextTickValue
bool CChartDateTimeAxis::GetNextTickValue(double dCurrentTick, double& dNextTick) const
{
if (m_MinValue == m_MaxValue)
return false;
COleDateTime dtTick((DATE)dCurrentTick);
COleDateTimeSpan dtSpan;
switch (m_BaseInterval)
{
case tiSecond:
dtSpan.SetDateTimeSpan(0,0,0,m_iDTTickIntervalMult);
dtTick += dtSpan;
break;
case tiMinute:
dtSpan.SetDateTimeSpan(0,0,m_iDTTickIntervalMult,0);
dtTick += dtSpan;
break;
case tiHour:
dtSpan.SetDateTimeSpan(0,m_iDTTickIntervalMult,0,0);
dtTick += dtSpan;
break;
case tiDay:
dtSpan.SetDateTimeSpan(m_iDTTickIntervalMult,0,0,0);
dtTick += dtSpan;
break;
case tiMonth:
dtTick = AddMonthToDate(dtTick,m_iDTTickIntervalMult);
break;
case tiYear:
dtTick = AddMonthToDate(dtTick,12*m_iDTTickIntervalMult);
break;
}
dNextTick = (DATE)dtTick;
if (dNextTick <= m_MaxValue)
return true;
else
return false;
}
示例4: GetFirstTickValue
double CChartDateTimeAxis::GetFirstTickValue() const
{
double dRetVal = m_dFirstTickValue;
if (m_bDiscrete)
{
COleDateTime dtTick((DATE)m_dFirstTickValue);
COleDateTimeSpan dtSpan;
switch (m_BaseInterval)
{
case tiSecond:
dtSpan.SetDateTimeSpan(0,0,0,m_iDTTickIntervalMult);
dtTick -= dtSpan;
break;
case tiMinute:
dtSpan.SetDateTimeSpan(0,0,m_iDTTickIntervalMult,0);
dtTick -= dtSpan;
break;
case tiHour:
dtSpan.SetDateTimeSpan(0,m_iDTTickIntervalMult,0,0);
dtTick -= dtSpan;
break;
case tiDay:
dtSpan.SetDateTimeSpan(m_iDTTickIntervalMult,0,0,0);
dtTick -= dtSpan;
break;
case tiMonth:
dtTick = AddMonthToDate(dtTick,-m_iDTTickIntervalMult);
break;
case tiYear:
dtTick = AddMonthToDate(dtTick,-12*m_iDTTickIntervalMult);
break;
}
}
return dRetVal;
}
示例5: UpdateDischargeDate
void VirtualMeasurement::UpdateDischargeDate()
{
//if (_iMPMeasurementType == AssemblyVerification)
{
if (_fMPCoolingTime < 0.0f)
_fMPCoolingTime = 0.0;
// change discharge date to conform to the cooling time
// cooling time is in years
COleDateTimeSpan coolings;
int secs = int(24.0*60.0*60.0 * 365.0 * _fMPCoolingTime);
coolings.SetDateTimeSpan(0, 0, 0, secs);
COleDateTime dd = _iMPMeasurementDateTime - coolings;
_iMPDischargeDateYear = dd.GetYear();
_iMPDischargeDateMonth = dd.GetMonth();
_iMPDischargeDateDay = dd.GetDay();
}
}
示例6: CalcScaleIntervalBegin
COleDateTime CXTPCalendarTLV_TimeScaleParams::CalcScaleIntervalBegin(
COleDateTime dtStart)
{
if (!m_scaleInterval.m_nValue)
{
ASSERT(FALSE);
return dtStart;
}
COleDateTime dtBegin = dtStart;
int nFirstDayOfWeekIndex = 0;
COleDateTimeSpan spAdd;
LONGLONG nVal = 0;
LONGLONG nDiv = 0;
//int nMod = 0;
LONGLONG nNewVal = 0;
LONGLONG nllDays_total = (int)(DATE)dtStart;
switch (m_scaleInterval.m_eType)
{
case xtpDTScale_Sec:
nVal = dtStart.GetSecond() + nllDays_total * 24 * 60 * 60;
nDiv = nVal / m_scaleInterval.m_nValue;
nNewVal = nDiv * m_scaleInterval.m_nValue;
dtBegin = (DATE)(nNewVal / (24 * 60 * 60));
dtBegin = CXTPCalendarUtils::UpdateTime(dtBegin, (int)(nNewVal % (24 * 60 * 60)),
(int)(nNewVal % (60 * 60)), (int)(nNewVal % 60));
/*nVal = dtStart.GetSecond();
nDiv = nVal / m_scaleInterval.m_nValue;
//nMod = nVal % m_scaleInterval.m_nValue;
nNewVal = (nDiv + (nMod ? 1 : 0)) * m_scaleInterval.m_nValue;
spAdd.SetDateTimeSpan(0, 0, 0, nNewVal);
dtBegin = CXTPCalendarUtils::UpdateTime(dtBegin, dtStart.GetHour(), dtStart.GetMinute(), 0);
dtBegin += spAdd;*/
break;
case xtpDTScale_Min:
nVal = dtStart.GetMinute() /*+ (dtStart.GetSecond() ? 1 : 0)*/;
nDiv = nVal / m_scaleInterval.m_nValue;
//nMod = nVal % m_scaleInterval.m_nValue;
//nNewVal = (nDiv +(nMod?1:0)) * m_scaleInterval.m_nValue;
nNewVal = nDiv * m_scaleInterval.m_nValue;
spAdd.SetDateTimeSpan(0, 0, (int)nNewVal, 0);
dtBegin = CXTPCalendarUtils::UpdateTime(dtStart, dtStart.GetHour(), 0, 0);
dtBegin += spAdd;
break;
case xtpDTScale_Hour:
nVal = dtStart.GetHour();
nDiv = nVal / m_scaleInterval.m_nValue;
nNewVal = (nDiv) * m_scaleInterval.m_nValue;
spAdd.SetDateTimeSpan(0, (int)nNewVal, 0, 0);
dtBegin = CXTPCalendarUtils::ResetTime(dtBegin);
dtBegin += spAdd;
break;
case xtpDTScale_Day:
nVal = dtStart.GetDay();
nDiv = nVal / m_scaleInterval.m_nValue;
nNewVal = (nDiv) * m_scaleInterval.m_nValue;
//spAdd.SetDateTimeSpan((int)max(0, nNewVal - 1), 0, 0, 0);
//dtBegin = CXTPCalendarUtils::ResetTime(dtBegin);
//CXTPCalendarUtils::UpdateMonthDay(dtBegin, 1);
//dtBegin += spAdd;
dtBegin = CXTPCalendarUtils::ResetTime(dtBegin);
CXTPCalendarUtils::UpdateMonthDay(dtBegin, (int)nNewVal);
break;
case xtpDTScale_Week:
// update first day of week
nFirstDayOfWeekIndex = XTP_SAFE_GET3(m_pTimeScale, GetView(), GetCalendarControl(), GetFirstDayOfWeek(), 2);
dtBegin = CXTPCalendarUtils::ShiftDateToWeekBegin(dtStart, nFirstDayOfWeekIndex);
nVal = (int)(DATE)dtStart;
nDiv = nVal / m_scaleInterval.m_nValue;
nNewVal = (nDiv) * m_scaleInterval.m_nValue;
dtBegin = (DATE)nNewVal;
break;
case xtpDTScale_WorkWeek:
// update first day of week
nFirstDayOfWeekIndex = XTP_SAFE_GET3(m_pTimeScale, GetView(), GetCalendarControl(), GetFirstDayOfWeek(), 2);
dtBegin = CXTPCalendarUtils::ShiftDateToWeekBegin(dtStart, nFirstDayOfWeekIndex);
nVal = (int)(DATE)dtStart;
nDiv = nVal / m_scaleInterval.m_nValue;
//.........这里部分代码省略.........
示例7: GetTickBeforeVal
double CChartDateTimeAxis::GetTickBeforeVal(double dValue) const
{
double precision = 0.0000000001;
if (dValue < 0)
precision = -0.0000000001;
COleDateTime tickBefore;
COleDateTime valueTime = COleDateTime(DATE(dValue+precision));
COleDateTimeSpan dtSpan = valueTime - m_ReferenceTick;
switch (m_BaseInterval)
{
case tiSecond:
{
int totalSecs = (int)dtSpan.GetTotalSeconds();
totalSecs = (totalSecs/m_iDTTickIntervalMult) * m_iDTTickIntervalMult;
int Days = totalSecs/86400; // 86400 seconds in one day
int Hours = (totalSecs%86400)/3600; // 3600 seconds in one hour
int Minutes = ((totalSecs%86400)%3600)/60; // 60 seconds in one minute
int Seconds = ((totalSecs%86400)%3600)%60;
dtSpan.SetDateTimeSpan(Days, Hours, Minutes, Seconds);
tickBefore = m_ReferenceTick + dtSpan;
}
break;
case tiMinute:
{
int totalMinutes = (int)dtSpan.GetTotalMinutes();
totalMinutes = (totalMinutes/m_iDTTickIntervalMult) * m_iDTTickIntervalMult;
int Days = totalMinutes/1440; // 1440 minutes in one day
int Hours = (totalMinutes%1440)/60; // 60 minutes in one hour
int Minutes = (totalMinutes%1440)%60;
dtSpan.SetDateTimeSpan(Days, Hours, Minutes, 0);
tickBefore = m_ReferenceTick + dtSpan;
}
break;
case tiHour:
{
int totalHours = (int)dtSpan.GetTotalHours();
totalHours = (totalHours/m_iDTTickIntervalMult) * m_iDTTickIntervalMult;
int Days = totalHours/24; // 24 hours in one day
int Hours = totalHours%24;
dtSpan.SetDateTimeSpan(Days, Hours, 0, 0);
tickBefore = m_ReferenceTick + dtSpan;
}
break;
case tiDay:
{
int totalDays = (int)dtSpan.GetTotalDays();
totalDays = (totalDays/m_iDTTickIntervalMult) * m_iDTTickIntervalMult;
dtSpan.SetDateTimeSpan(totalDays, 0, 0, 0);
tickBefore = m_ReferenceTick + dtSpan;
}
break;
case tiMonth:
{
int yearDiff = valueTime.GetYear() - m_ReferenceTick.GetYear();
int monthDiff = valueTime.GetMonth() - m_ReferenceTick.GetMonth();
int totalMonths = ((yearDiff*12+monthDiff)/m_iDTTickIntervalMult) * m_iDTTickIntervalMult;
tickBefore = AddMonthToDate(m_ReferenceTick,totalMonths);
}
break;
case tiYear:
{
int yearDiff = valueTime.GetYear() - m_ReferenceTick.GetYear();
int year = ((yearDiff)/m_iDTTickIntervalMult) * m_iDTTickIntervalMult;
tickBefore = AddMonthToDate(m_ReferenceTick,year*12);
}
break;
}
return (DATE)tickBefore;
}
示例8: Draw
void CXTPCalendarDayViewTimeScale::Draw(CDC* pDC)
{
ASSERT(pDC && m_pDayView);
if (!pDC || !m_pDayView)
{
return;
}
pDC->FillSolidRect(m_Layout.m_rcHeader, GetSysColor(COLOR_3DFACE));
pDC->SetBkMode(TRANSPARENT);
int nRowHeight = XTP_SAFE_GET1(m_pDayView, GetRowHeight(), 0);
if (nRowHeight <= 0)
return;
const int nRowCount = m_pDayView->GetVisibleRowCount();
const int nTopRow = m_pDayView->GetTopRow();
COleDateTimeSpan spScaleInterval = GetScaleInterval();
if (CXTPCalendarUtils::GetTotalMinutes(spScaleInterval) < 1)
{
ASSERT(FALSE);
spScaleInterval.SetDateTimeSpan(0, 0, 5, 0);
}
//=== Calculate 'now' line. Draw it's BK ================================
int nNowLineY = 0;
if (m_bDrawNowLineDyn)
{
int nBottomRow = nTopRow + m_pDayView->GetVisibleRowCount();
COleDateTime dtTopTime = m_pDayView->GetCellTime(nTopRow);
COleDateTime dtBottomTime = m_pDayView->GetCellTime(nBottomRow);
COleDateTimeSpan spView = dtBottomTime - dtTopTime;
COleDateTime dtNow = CXTPCalendarUtils::GetCurrentTime();
dtNow = CXTPCalendarUtils::ResetDate(dtNow);
COleDateTimeSpan spNow = dtNow - dtTopTime;
double dPixelPerSecond = m_Layout.m_rcTimeZone.Height() / (double)CXTPCalendarUtils::GetTotalSeconds(spView);
int nDlta = int(CXTPCalendarUtils::GetTotalSeconds(spNow) * dPixelPerSecond);
nNowLineY = m_Layout.m_rcTimeZone.top + nDlta;
XTP_SAFE_CALL3(m_pDayView, GetPaintManager(), GetDayViewTimeScaleHeaderPart(),
DrawNowLine(pDC, m_pDayView, m_Layout.m_rcTimeZone, nNowLineY, TRUE) );
}
//================================================================
int nTimeShiftCorrectorY = 0;
COleDateTimeSpan spShiftCorrector(0);
int nScaleInterval_min = max(1, (int)CXTPCalendarUtils::GetTotalMinutes(spScaleInterval));
double dPixelPerMin = (double)nRowHeight / (double)nScaleInterval_min;
if (CXTPCalendarUtils::GetTotalHours(spScaleInterval) < 1)
{
int nMul = m_nTimeshift_min / 60;
int nMod = m_nTimeshift_min % 60;
int nShiftCorrector_min = (nMul + (nMod ? 1 :0))*60 - m_nTimeshift_min;
//-------------------------------------------------------------------
int nMul2 = nShiftCorrector_min / nScaleInterval_min;
int nMod2 = nShiftCorrector_min % nScaleInterval_min;
int nShiftCorrector2_min = (nMul2 + (nMod2 ? 1 :0)) * nScaleInterval_min;
nTimeShiftCorrectorY = (int)(dPixelPerMin * nShiftCorrector2_min);
spShiftCorrector = CXTPCalendarUtils::Minutes2Span(nShiftCorrector_min);
}
// draw time scale header
COleDateTimeSpan spShift = CXTPCalendarUtils::Minutes2Span(m_nTimeshift_min);
// draw time scale rows
if (CXTPCalendarUtils::GetTotalHours(spScaleInterval) >= 1)
{
// draw time scale cells one by one
for (int i = 0; i < nRowCount; i++)
{
CRect rcCell(m_Layout.m_rcTimeZone.left,
m_Layout.m_rcTimeZone.top + nRowHeight * i,
m_Layout.m_rcTimeZone.right,
m_Layout.m_rcTimeZone.top + nRowHeight * (i + 1));
COleDateTime dtTime = m_pDayView->GetCellTime(nTopRow + i);
dtTime += spShift;
CString str = Format(dtTime, FALSE);
XTP_SAFE_CALL3(m_pDayView, GetPaintManager(), GetDayViewTimeScaleCellPart(),
DrawHourCell(pDC, rcCell, str, FALSE));
}
}
else
{
COleDateTimeSpan spHour(0, 1, 0, 0);
spShift += spShiftCorrector;
//.........这里部分代码省略.........