当前位置: 首页>>代码示例>>C++>>正文


C++ DTime::GetTime方法代码示例

本文整理汇总了C++中DTime::GetTime方法的典型用法代码示例。如果您正苦于以下问题:C++ DTime::GetTime方法的具体用法?C++ DTime::GetTime怎么用?C++ DTime::GetTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DTime的用法示例。


在下文中一共展示了DTime::GetTime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetDataToFetch

DatabaseQuery* Draw::GetDataToFetch() {
	const DTime& start_time = m_index.GetStartTime();
	assert(start_time.IsValid());

	PeriodType period = start_time.GetPeriod();

	int d = m_values.m_view.Start();

	DatabaseQuery* q = NULL;

	if (m_draw_info == NULL)
		return q;

	if (GetEnable() == false)
		return q;

	bool no_max_probes = !m_draw_info->IsValid() || m_draw_info->GetParam()->GetIPKParam()->GetFormulaType() == TParam::LUA_AV;
	for (size_t i = 0; i < m_values.len(); ++i) {
		ValueInfo &v = m_values.Get(i);

		if (v.state != ValueInfo::EMPTY) 
			continue;
		
		DTime pt = GetDTimeOfIndex(i - d);
		if (period == PERIOD_T_DAY)
			v.max_probes = 1;
		else if (no_max_probes)
			v.max_probes = 0;
		else {
			DTime ptn = pt + m_index.GetDateRes() + m_index.GetTimeRes();
			v.max_probes = (ptn.GetTime() - pt.GetTime()).GetMinutes() / 10;
		}

		v.state = ValueInfo::PENDING;
		
		if (q == NULL)
			q = CreateDataQuery(m_draw_info, period, m_draw_no);
		AddTimeToDataQuery(q, pt.GetTime().GetTicks());
	}

	return q;
}
开发者ID:cyclefusion,项目名称:szarp,代码行数:42,代码来源:draw.cpp

示例2: OnDateChange

void XYDialog::OnDateChange(wxCommandEvent &event) {
	wxButton *button;
	DTime *time;

	if (event.GetId() == XY_START_TIME) {
		button = wxDynamicCast(FindWindow(XY_START_TIME), wxButton);
		time = &m_start_time;
	} else {
		button = wxDynamicCast(FindWindow(XY_END_TIME), wxButton);
		time = &m_end_time;
	}

	DateChooserWidget *dcw = 
		new DateChooserWidget(
				this,
				_("Select date"),
				1,
				-1,
				-1,
				1
		);

	wxDateTime wxtime = time->GetTime();
	
	bool ret = dcw->GetDate(wxtime);
	dcw->Destroy();

	if (ret == false)
		return;

	*time = DTime(m_period, wxtime);
	time->AdjustToPeriod();

	button->SetLabel(FormatTime(time->GetTime(), m_period));

}
开发者ID:cyclefusion,项目名称:szarp,代码行数:36,代码来源:xydiag.cpp

示例3: AdjustToPeriodSpan

DTime TimeIndex::AdjustToPeriodSpan(const DTime &time) const {
	wxDateTime dt = time.GetTime();

	if (m_number_of_values == default_units_count[time.GetPeriod()] * PeriodMult[time.GetPeriod()]) {
		switch (time.GetPeriod()) {
			case PERIOD_T_DECADE :
			case PERIOD_T_YEAR :
				dt.SetMonth(wxDateTime::Jan);
			case PERIOD_T_MONTH :
				dt.SetDay(1);
				dt.SetHour(0);
				break;
			case PERIOD_T_WEEK:
			case PERIOD_T_SEASON :
				dt.SetToWeekDayInSameWeek(wxDateTime::Mon);
			case PERIOD_T_DAY :
				dt.SetHour(0);
				dt.SetMinute(0);
				break;
			case PERIOD_T_30MINUTE :
				dt.SetMinute(dt.GetMinute() / 30 * 30);
				dt.SetSecond(0);
				break;
			case PERIOD_T_5MINUTE :
				dt.SetMinute(dt.GetMinute() / 3 * 3);
				dt.SetSecond(0);
				break;
			case PERIOD_T_MINUTE :
			case PERIOD_T_30SEC :
				dt.SetSecond(dt.GetSecond() / 30 * 30);
				break;
			case PERIOD_T_OTHER:
			case PERIOD_T_LAST:
				assert(false);
		}
		return DTime(time.GetPeriod(), dt);
	} else {
		DTime ret(time);
		return ret.AdjustToPeriodStart();
	}
}
开发者ID:Strongc,项目名称:szarp,代码行数:41,代码来源:drawtime.cpp

示例4: GetDistance

int DTime::GetDistance(const DTime &t) const {
	assert(IsValid());
	assert(t.IsValid());

	if (GetPeriod() != t.GetPeriod()) {
		wxLogError(_T("our period: %d, his period: %d"), GetPeriod(), t.GetPeriod());
		assert(false);
	}

	const wxDateTime& _t0 = GetTime();
	const wxDateTime& _t = t.GetTime();

	int ret = -1;

	switch (GetPeriod()) {
		case PERIOD_T_DECADE:
			ret = _t.GetYear() - _t0.GetYear();
			break;
		case PERIOD_T_YEAR:
			ret = _t.GetYear() * 12 + _t.GetMonth()
				- _t0.GetYear() * 12 - _t0.GetMonth();
			break;
		case PERIOD_T_MONTH: 
			ret = (_t - _t0).GetHours();
			//acount for daylight saving time
			switch (ret % 24) {
				case 1:
					ret -= 1;
					break;
				case 23:
					ret += 1;
					break;
				case -1:
					ret += 1;
					break;
				case -23:
					ret -= 1;
					break;
			}
			ret /= 24;
			break;
		case PERIOD_T_DAY:
			ret = (_t - _t0).GetMinutes() / 10;
			break;
		case PERIOD_T_30MINUTE:
			ret = ((_t - _t0).GetSeconds() / 10).ToLong();
			break;
		case PERIOD_T_5MINUTE:
			ret = ((_t - _t0).GetSeconds()).ToLong();
			break;
		case PERIOD_T_MINUTE:
			ret = ((_t - _t0).GetMilliseconds() / 500).ToLong();
			break;
		case PERIOD_T_30SEC:
			ret = ((_t - _t0).GetMilliseconds() / 100).ToLong();
			break;
		case PERIOD_T_WEEK:
			ret = (_t - _t0).GetHours() / 8;
			if (_t0.IsDST() != _t.IsDST()) {
				if (_t0 < _t && _t.IsDST())
					ret += 1;
				else if (_t < _t0 && _t0.IsDST())
					ret -= 1;
			}
			break;
		case PERIOD_T_SEASON: 
			ret = (_t - _t0).GetDays() / 7;
			if (_t0.IsDST() != _t.IsDST()) {
				if (_t0 < _t && _t.IsDST())
					ret += 1;
				else if (_t < _t0 && _t0.IsDST())
					ret -= 1;
			}
			break;
		default:
			assert(false);
	}

	return ret;
}
开发者ID:Strongc,项目名称:szarp,代码行数:80,代码来源:drawtime.cpp


注:本文中的DTime::GetTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。