本文整理汇总了C++中boost::posix_time::ptime类的典型用法代码示例。如果您正苦于以下问题:C++ ptime类的具体用法?C++ ptime怎么用?C++ ptime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ptime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetDateTimeEvents
std::vector<DateTimeEventsManager::EventStartTimePair> DateTimeEventsManager::GetEventsNearestStartTime() const
{
std::vector<EventStartTimePair> result;
const std::vector<DateTimeEvent*> dateTimeEvents = GetDateTimeEvents();
for (auto it = dateTimeEvents.begin(); it != dateTimeEvents.end(); ++it)
{
DateTimeEvent* event = *it;
const boost::posix_time::ptime eventStartTime = GetEventStartTime(event);
// Skip once events in the past.
if (eventStartTime.is_not_a_date_time())
{
continue;
}
result.push_back(std::make_pair(event, eventStartTime));
}
std::sort(result.begin(), result.end(),
boost::bind(&EventStartTimePair::second, _1) < boost::bind(&EventStartTimePair::second, _2));
return result;
}
开发者ID:andrewsmolko,项目名称:foo_scheduler,代码行数:25,代码来源:date_time_events_manager.cpp
示例2: hash_value
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
示例3: 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
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: 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
示例9:
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
示例10: toString
std::string TimeConversion::toString(const boost::posix_time::ptime ts, const int secPrecision) const
{
using namespace boost::posix_time;
// determine the nanoseconds given in ts
const int h = ts.time_of_day().hours();
const int m = ts.time_of_day().minutes();
const int s = ts.time_of_day().seconds();
const time_duration r = time_duration(h, m, s);
const time_duration rest = ts.time_of_day() - r;
const int nanoseconds = int(rest.total_nanoseconds()); // not more than 1 bil nanoseconds here.
return toString(to_tm(ts), nanoseconds, secPrecision);
}
开发者ID:jannickep,项目名称:snowbots,代码行数:14,代码来源: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: readTag
void readTag( const std::string& tag, Session& session, const boost::posix_time::ptime& snapshotTime ){
IOVProxy proxy;
if( snapshotTime.is_not_a_date_time() ) proxy = session.readIov( tag );
else proxy = session.readIov( tag, snapshotTime );
std::cout <<"> iov loaded size="<<proxy.loadedSize()<<std::endl;
std::cout <<"> iov sequence size="<<proxy.sequenceSize()<<std::endl;
IOVProxy::Iterator iovIt = proxy.find( 107 );
if( iovIt == proxy.end() ){
std::cout <<">[0] not found!"<<std::endl;
} else {
cond::Iov_t val = *iovIt;
std::cout <<"#[0] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl;
boost::shared_ptr<std::string> pay0 = session.fetchPayload<std::string>( val.payloadId );
std::cout <<"#[0] payload="<<*pay0<<std::endl;
}
iovIt = proxy.find( 235 );
if( iovIt == proxy.end() ){
std::cout <<">[1] not found!"<<std::endl;
} else {
cond::Iov_t val = *iovIt;
std::cout <<"#[1] iov since="<<val.since<<" till="<<val.till<<" pid="<<val.payloadId<<std::endl;
boost::shared_ptr<std::string> pay0 = session.fetchPayload<std::string>( val.payloadId );
std::cout <<"#[1] payload="<<*pay0<<std::endl;
}
}
开发者ID:cmsuk-track-trigger,项目名称:cmssw,代码行数:25,代码来源:testConditionDatabase_1.cpp
示例13: findNextrun
boost::posix_time::ptime
MetaModelConf::
findNextrun(const boost::posix_time::ptime &refTime)const
{
ptime now( (nowTime__.is_special()?second_clock::universal_time():nowTime__) );
ptime midnight( now.date(), time_duration(0, 0, 0, 0) );
time_duration tdNow( now.time_of_day() );
if( nextrun_.empty() )
return ptime(); //Udefined.
if( specType==Absolute) {
TimeDurationList::const_iterator it=nextrun_.begin();
for( ; it != nextrun_.end() && *it < tdNow ; ++it );
if( it == nextrun_.end() ) {
midnight += hours( 24 ); //next day
it = nextrun_.begin();
}
return midnight + *it;
} else if( specType == RelativeToLoadTime ){
if( refTime.is_special() || nextrun_.empty())
return ptime(); // undefined
return refTime + (*nextrun_.begin());
} else {
return ptime(); // Undefined
}
}
开发者ID:metno,项目名称:wdb2ts,代码行数:31,代码来源:MetaModelConf.cpp
示例14:
void
cluster_helper_c::create_tags_for_track_statistics(KaxTags &tags,
std::string const &writing_app,
boost::posix_time::ptime const &writing_date) {
auto writing_date_str = !writing_date.is_not_a_date_time() ? mtx::date_time::to_string(writing_date, "%Y-%m-%d %H:%M:%S") : "1970-01-01 00:00:00";
for (auto const &ptzr : g_packetizers) {
auto track_uid = ptzr.packetizer->get_uid();
auto const &stats = m->track_statistics[track_uid];
auto bps = stats.get_bits_per_second();
auto duration = stats.get_duration();
mtx::tags::remove_simple_tags_for<KaxTagTrackUID>(tags, track_uid, "BPS");
mtx::tags::remove_simple_tags_for<KaxTagTrackUID>(tags, track_uid, "DURATION");
mtx::tags::remove_simple_tags_for<KaxTagTrackUID>(tags, track_uid, "NUMBER_OF_FRAMES");
mtx::tags::remove_simple_tags_for<KaxTagTrackUID>(tags, track_uid, "NUMBER_OF_BYTES");
auto tag = mtx::tags::find_tag_for<KaxTagTrackUID>(tags, track_uid, mtx::tags::Movie, true);
mtx::tags::set_target_type(*tag, mtx::tags::Movie, "MOVIE");
mtx::tags::set_simple(*tag, "BPS", to_string(bps ? *bps : 0));
mtx::tags::set_simple(*tag, "DURATION", format_timecode(duration ? *duration : 0));
mtx::tags::set_simple(*tag, "NUMBER_OF_FRAMES", to_string(stats.get_num_frames()));
mtx::tags::set_simple(*tag, "NUMBER_OF_BYTES", to_string(stats.get_num_bytes()));
mtx::tags::set_simple(*tag, "_STATISTICS_WRITING_APP", writing_app);
mtx::tags::set_simple(*tag, "_STATISTICS_WRITING_DATE_UTC", writing_date_str);
mtx::tags::set_simple(*tag, "_STATISTICS_TAGS", "BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES");
}
m->track_statistics.clear();
}
开发者ID:RaceOfAce,项目名称:mkvtoolnix,代码行数:33,代码来源:cluster_helper.cpp
示例15: 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
示例16: to_ntp_time
std::pair< comma::uint32, comma::uint32 > to_ntp_time( boost::posix_time::ptime t )
{
if( t < ntp_base ) { COMMA_THROW_STREAM( comma::exception, "cannot convert to ntp time: " << t << ", which is less than NTP time base " << ntp_base ); }
comma::int32 s = ( t - epoch_time ).total_seconds(); // 32 bit signed int in boost and posix
comma::int32 m = t.time_of_day().total_microseconds() % 1000000;
if( t >= epoch_time || m == 0 )
{
return std::pair< comma::uint32, comma::uint32 >( static_cast< comma::uint32 >( ntp_diff + s ), static_cast< comma::uint32 >( m / ntp_microsec_coeff ) );
}
else
{
return std::pair< comma::uint32, comma::uint32 >( static_cast< comma::uint32 >( ntp_diff + s - 1 ), static_cast< comma::uint32 >( m / ntp_microsec_coeff ) );
}
}
开发者ID:ahmmedshakil,项目名称:snark,代码行数:14,代码来源:ntp.cpp
示例17: expire
void
webfw::
DefaultResponse::
expire( const boost::posix_time::ptime &exp )
{
Response::expire( exp );
if( ! exp.is_special() ) {
std::string rfc1123;
rfc1123 = miutil::rfc1123date( exp );
if( ! rfc1123.empty() )
out_ << "Expire: " << rfc1123 << std::endl;
}
}
开发者ID:metno,项目名称:wdb2ts,代码行数:15,代码来源:DefaultResponse.cpp
示例18: bind
void
PreparedStatement::bind(size_t param, const boost::posix_time::ptime &value)
{
if (value.is_not_a_date_time()) {
bind(param, Null());
return;
}
ensure(param);
m_paramValues[param - 1].resize(8);
long long ticks = (value - postgres_epoch).total_microseconds();
*(long long *)&m_paramValues[param - 1][0] = byteswapOnLittleEndian(*(long long *)&ticks);
m_params[param - 1] = m_paramValues[param - 1].c_str();
m_paramLengths[param - 1] = m_paramValues[param - 1].size();
m_paramFormats[param - 1] = 1;
setType(param, TIMESTAMPOID);
}
开发者ID:fathomdb,项目名称:mordor,代码行数:16,代码来源:preparedstatement.cpp
示例19: getAlpha
double getAlpha(
boost::posix_time::ptime& tstamp_prev,
double max_life)
{
auto now = boost::posix_time::microsec_clock::universal_time();
double alpha = 1.0; // Default is 100% opacity.
if (!tstamp_prev.is_not_a_date_time())
{
// alpha = min {delta_t, max_life} / max_life
auto tdelta = now - tstamp_prev;
alpha = tdelta.total_nanoseconds()/1000000000.;
alpha = std::min(alpha, max_life);
alpha /= max_life;
}
tstamp_prev = now;
return alpha;
}
开发者ID:vmlaker,项目名称:sherlock-cpp,代码行数:17,代码来源:util.cpp
示例20: appendEntryToFile
void HistoryManager::appendEntryToFile(std::ofstream &os, bool isSent, const boost::posix_time::ptime &saveTime, const std::string &content)
{
if(saveTime.is_not_a_date_time())
return;
if(os.tellp() != 0)
os << std::endl;
os << "[" << FormattingUtils::dateToStr(saveTime) << "]";
if(isSent)
{
os << "-S-";
}
else
{
os << "-R-";
}
os << content;
}
开发者ID:ntszar,项目名称:axg,代码行数:17,代码来源:historymanager.cpp
注:本文中的boost::posix_time::ptime类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论