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


C++ ptime::date方法代码示例

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


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

示例1: ValToBuf

int CH104_Transmit::AssembleSynTime(size_t bufIndex, unsigned char * buf, stSynTimePara para,boost::posix_time::ptime time)
{
	size_t count = bufIndex;

	buf[count++] = 0x68;
	count += ValToBuf(&buf[count],0,FrameLenLength_);
	count += ValToBuf(&buf[count],para.IFrameSendCounter_,2);
	count += ValToBuf(&buf[count],para.IFrameRecvCounter_,2);
	count += ValToBuf(&buf[count],M_CS_NA_1,FrameTypeLength_);
	count += ValToBuf(&buf[count],0x01,InfoNumLength_);
	count += ValToBuf(&buf[count],trans_act,TransReasonLength_);
	count += ValToBuf(&buf[count],para.addr_,AsduAddrLength_);
	count += ValToBuf(&buf[count],0,InfoAddrLength_);
	boost::posix_time::time_duration td = time.time_of_day();
	count += ValToBuf(&buf[count],td.total_milliseconds() % MinutesRemainderMillisecs,2);
	buf[count++] = td.minutes() & 0x3f;
	buf[count++] = td.hours() & 0x1f;
	boost::gregorian::date::ymd_type ymd = time.date().year_month_day();
	//buf[count++] = ymd.day & 0x1f;
	buf[count++] = ((time.date().day_of_week()<<5) & 0xe0) | (ymd.day & 0x1f);
	buf[count++] = ymd.month & 0x0f;
	buf[count++] = ymd.year % 100;

	int len = count - bufIndex - (FrameLenLength_ + SYN_HEAD_LENGTH);
	ValToBuf(&buf[FrameLenLocation_],len,FrameLenLength_);

	return count - bufIndex;
}
开发者ID:bianfupolestar,项目名称:DAT2C,代码行数:28,代码来源:H104_Transmit.cpp

示例2: set_from_ptime

/** Sets the date and time using a boost::posix_time::ptime
 *
 * @param _ptime :: boost::posix_time::ptime date and time.
 */
void DateAndTime::set_from_ptime(boost::posix_time::ptime _ptime) {
  if (_ptime.is_special()) {
    // --- SPECIAL VALUES! ----
    if (_ptime.is_infinity() || _ptime.is_pos_infinity())
      _nanoseconds = MAX_NANOSECONDS;
    if (_ptime.is_neg_infinity())
      _nanoseconds = MIN_NANOSECONDS;
    if (_ptime.is_not_a_date_time())
      _nanoseconds = MIN_NANOSECONDS;
  } else {
    _nanoseconds =
        nanosecondsFromDuration(_ptime - DateAndTimeHelpers::GPS_EPOCH);

    // Check for overflow
    if (_nanoseconds < 0) {
      if (_ptime.date().year() >= 1990) {
        // nanoseconds is negative despite the year being higher than 1990
        // ... means overflow occured
        this->setToMaximum();
      }
    } else if (_nanoseconds > 0) {
      if (_ptime.date().year() < 1990) {
        // Nanoseconds is positive but the year is below 1990 = it should be
        // negative!
        this->setToMinimum();
      }
    }
  }
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:33,代码来源:DateAndTime.cpp

示例3: af_timestamp

string AutoFlight::af_timestamp()
{
	const boost::posix_time::ptime time = boost::posix_time::second_clock::local_time();

	stringstream timestamp;
	timestamp << setw(4) << setfill('0') << time.date().year() << setw(2) << time.date().month().as_number() << setw(2) << time.date().day().as_number();
	timestamp << "T";
	timestamp << setw(2) << time.time_of_day().hours() << setw(2) << time.time_of_day().minutes() << setw(2) << time.time_of_day().seconds();

	return timestamp.str();
}
开发者ID:dan-hill,项目名称:AutoFlight_v1,代码行数:11,代码来源:autoflight.cpp

示例4:

    void BindArgDataHolder::ArgSetter::operator()( MYSQL_BIND &arg, const boost::posix_time::ptime &datetime )
    {
        MYSQL_TIME *ts = reinterpret_cast<MYSQL_TIME *>( arg.buffer );

        ts->year   = datetime.date().year();
        ts->month  = datetime.date().month();
        ts->day    = datetime.date().day();
        ts->hour   = datetime.time_of_day().hours();
        ts->minute = datetime.time_of_day().minutes();
        ts->second = datetime.time_of_day().seconds();

    }
开发者ID:tianqi22,项目名称:modosmapi,代码行数:12,代码来源:dbhandler.cpp

示例5:

    inline boost::uint64_t hash_value(const boost::posix_time::ptime& value, boost::uint64_t seed)
    {
        seed = hash_value(value.date(), seed);
        seed = hash_value(value.time_of_day(), seed);

        return seed;
    }
开发者ID:llawall,项目名称:protean,代码行数:7,代码来源:hash.hpp

示例6: pttoqt

QDateTime pttoqt(const boost::posix_time::ptime &pt) {
	boost::gregorian::date gd = pt.date();
	boost::posix_time::time_duration gt = pt.time_of_day();
	QDate qdate(gd.year(), gd.month(), gd.day());
	QTime qtime(gt.hours(), gt.minutes(), gt.seconds());

	return QDateTime(qdate, qtime);
}
开发者ID:gregorburger,项目名称:CityDrain3,代码行数:8,代码来源:fileout.cpp

示例7: rotate_stores

  void rotate_stores()
		{
			std::cout << "Rotating store " << store_file << "..." << std::endl;
			std::cout << "Rotating store call flush " << store_file << "..." << std::endl;
      fflush(stdout);
			try {
        store->flush(true);
			} catch (klio::StoreException const& ex) {
				std::cout << "Failed to flush the buffers : " << ex.what() << std::endl;
      }
      std::cout << "Rotating store flushed " << store_file << "..." << std::endl;
      fflush(stdout);

			std::cout << "Reopening store" << std::endl;

      const boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();

      std::string s;
      s= str( format("%04d%02d%02d-%02d%02d")        % now.date().year_month_day().year
              % now.date().year_month_day().month.as_number()
              % now.date().year_month_day().day.as_number()
              % now.time_of_day().hours()
              % now.time_of_day().minutes());

      std::string name(store_file.string());
      name+=".";
      name+=s;
      
      bfs::path dbname(name);
      std::cout << "===> renaming to: "<< name<<std::endl;
      fflush(stdout);
			try {
        store->rotate(dbname);
			} catch (klio::StoreException const& ex) {
				std::cout << "Failed to rotate the klio-databse : " << ex.what() << std::endl;
      }
      

#if KLIO_AUTOCOMMIT
      store->start_transaction();
#endif

			std::cout << "Rotation done" << std::endl;
		}
开发者ID:florian-asche,项目名称:hexabus,代码行数:44,代码来源:hexalog.cpp

示例8: to_tm

 //! Convert a time to a tm structure truncating any fractional seconds
 inline
 std::tm to_tm(const boost::posix_time::ptime& t) {
   std::tm timetm = boost::gregorian::to_tm(t.date());
   boost::posix_time::time_duration td = t.time_of_day();
   timetm.tm_hour = td.hours();
   timetm.tm_min = td.minutes();
   timetm.tm_sec = td.seconds();
   timetm.tm_isdst = -1; // -1 used when dst info is unknown
   return timetm;
 }
开发者ID:knobik,项目名称:source-python,代码行数:11,代码来源:conversion.hpp

示例9: to_tm

 //! Convert a time to a tm structure truncating any fractional seconds 
 inline
 tm to_tm(const boost::posix_time::ptime& t) {
   tm timetm = boost::gregorian::to_tm(t.date());
   boost::posix_time::time_duration td = t.time_of_day();
   timetm.tm_hour = td.hours(); 
   timetm.tm_min = td.minutes(); 
   timetm.tm_sec = td.seconds();
   timetm.tm_isdst = -1; //?
   return timetm;
 }
开发者ID:DCMF,项目名称:Dawn-of-Civilization,代码行数:11,代码来源:conversion.hpp

示例10: FromBoostPtime

	static void FromBoostPtime(const boost::posix_time::ptime& pt, Time& t)
	{
		boost::gregorian::date d = pt.date();
		t.m_year = d.year();
		t.m_month = d.month();
		t.m_day = d.day();
		boost::posix_time::time_duration tod = pt.time_of_day();
		t.m_hour = tod.hours();
		t.m_minute = tod.minutes();
		t.m_second = tod.seconds();
		t.m_fraction_of_second = tod.fractional_seconds() / pow(10.0, tod.num_fractional_digits());
	}
开发者ID:reunanen,项目名称:Numcore_messaging_library,代码行数:12,代码来源:Time.cpp

示例11: append_timestamp

void append_timestamp(Stream& stream, boost::posix_time::ptime timestamp)
{
    auto date         = timestamp.date();
    auto time         = timestamp.time_of_day();
    auto milliseconds = time.fractional_seconds() / 1000; // microseconds to milliseconds

    std::wstringstream buffer;

    buffer << std::setfill(L'0') << L"[" << std::setw(4) << date.year() << L"-" << std::setw(2)
           << date.month().as_number() << "-" << std::setw(2) << date.day().as_number() << L" " << std::setw(2)
           << time.hours() << L":" << std::setw(2) << time.minutes() << L":" << std::setw(2) << time.seconds() << L"."
           << std::setw(3) << milliseconds << L"] ";

    stream << buffer.str();
}
开发者ID:CasparCG,项目名称:Server,代码行数:15,代码来源:log.cpp

示例12: Week

 int Week() { return t.date().week_number(); };
开发者ID:arrrrrrr,项目名称:ebftpd,代码行数:1,代码来源:time.hpp

示例13: ScanBars

void SignalGenerator::ScanBars( pt::ptime dtLast ) {

  pt::ptime dtBegin( dtLast.date() - gregorian::date_duration( 52 * 7 ), pt::time_duration( 0, 0, 0 ) ); // process ~year of bars

  try {

    m_xls.New( 1 );
    m_sheet = m_xls.GetWorksheet( 0 );
    ExcelFormat::BasicExcelCell* cell;
    ExcelFormat::CellFormat fmt(m_fmt_mgr);
    fmt.set_format_string( XLS_FORMAT_DECIMAL );
    fmt.set_alignment( ExcelFormat::EXCEL_HALIGN_CENTRED );
    int ix( 0 );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "Type" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "Symbol" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "Price" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "Volume" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "BolRange" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "SMA Sig" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "BolUpr" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "BolLwr" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "SMA1" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "SMA2" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "SMA3" );

    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "> PV" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "X Down" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "< R1 X Up" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "< R1 X Down" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "< PV" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "X Up" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "> S1 X Up" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "> S1 X Down" );
    cell = m_sheet->Cell( 0, ix++ );
    cell->SetFormat( fmt );
    cell->SetString( "PV X" );

    namespace ph = std::placeholders;
    mapSymbol_t::iterator iter;
    ou::tf::InstrumentFilter<mapSymbol_t::iterator,ou::tf::Bars> filter(
      "/bar/86400",  // at least a year's worth of bars
      dtBegin, dtLast, 200, iter,
      std::bind( &SignalGenerator::HandleCallBackUseGroup, this, ph::_1, ph::_2, ph::_3 ),
      std::bind( &SignalGenerator::HandleCallBackFilter,   this, ph::_1, ph::_2, ph::_3 ),
      std::bind( &SignalGenerator::HandleCallBackResults,  this, ph::_1, ph::_2, ph::_3 )
      );

    m_xls.SaveAs( "weeklies.xls" );
    m_xls.Close();  }

  catch( ... ) {
    std::cout << "Scan Problems" << std::endl;
  }
}
开发者ID:rburkholder,项目名称:trade-frame,代码行数:92,代码来源:SignalGenerator.cpp

示例14: write

        void write(string const&logLev, string info, boost::posix_time::ptime time)
        {
            int year = time.date().year();
            int month = time.date().month();
            int day = time.date().day();
            std::string time_str = boost::str(boost::format("%d-%02d-%02d")%year%month%day);
			boost::gregorian::date local_day = boost::gregorian::day_clock::local_day();
            std::string log_date_time = boost::gregorian::to_iso_extended_string(local_day);
			if(!time.time_of_day().is_special()) {
                char sep = ' ';
                time_str += sep + boost::posix_time::to_simple_string(time.time_of_day());
            }
			if (elog_factory::instance().get_root_path().empty())
			{
				return;
			}
			std::string destfileUtf = epfilesystem::instance().sub_path(elog_factory::instance().get_root_path(), "log");
			std::string fileName = log_date_time + "-" + file_name_;
			destfileUtf = epfilesystem::instance().sub_path(destfileUtf, fileName);
#ifdef _WIN32
			std::wstring destfile = UTF2WS(destfileUtf);
#else
			std::string destfile = destfileUtf;
#endif

            if(!ofs_)
			{
#ifdef _WIN32
				ofs_.reset(new ofstream(destfile.c_str(), (append_mode_?ios::app:0) | ios::binary ));
#else
                if(append_mode_)
                {
                    ofs_.reset(new std::ofstream(destfile.c_str(),ios::app | ios::binary));
                }
                else
                {
                    ofs_.reset(new std::ofstream(destfile.c_str(),ios::binary));
                }                
                
#endif                
			}
			
			// 客户端 IM-2941 密码明文显示的修改
			std::wstring bingo = L"\"user_passwd\":\"";
			std::wstring winfo = txtutil::convert_utf8_to_wcs(info);
			std::wstring::size_type index = std::wstring::npos;
			std::wstring::size_type eindex= std::wstring::npos;
			index = winfo.find(bingo);
			do{
				if (index != std::wstring::npos)
				{
					eindex = winfo.find(L'\"', index + bingo.length());
					if (eindex != std::wstring::npos)
					{
						winfo.erase(index + bingo.length(), eindex-index-bingo.length());
					}

					index = winfo.find(bingo, eindex);
				}
			}while(index != std::wstring::npos);

			info = txtutil::convert_wcs_to_utf8(winfo);

			std::string version_num = elog_factory::instance().get_version_num();
			if (version_num !="")
			{
				 *ofs_ << "[" + time_str +"-"+ version_num +"]" + logLev << ":\t"<<info << endl;
			}
			else
			{
            *ofs_ << "[" + time_str + "]" + logLev << ":\t"<<info << endl;
			}
            ofs_.reset();
        }
开发者ID:iVideo,项目名称:weishao,代码行数:74,代码来源:elog.cpp

示例15: Day

 int Day() { return t.date().day(); };
开发者ID:arrrrrrr,项目名称:ebftpd,代码行数:1,代码来源:time.hpp


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