本文整理汇总了C++中boost::posix_time::ptime::is_not_a_date_time方法的典型用法代码示例。如果您正苦于以下问题:C++ ptime::is_not_a_date_time方法的具体用法?C++ ptime::is_not_a_date_time怎么用?C++ ptime::is_not_a_date_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::posix_time::ptime
的用法示例。
在下文中一共展示了ptime::is_not_a_date_time方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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();
}
示例2: 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;
}
}
示例3: 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();
}
}
}
}
示例4: 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;
}
示例5: update
void update( const boost::posix_time::ptime& t, bool commit = false )
{
//std::cerr << "--> a: t_: " << ( t_ ? boost::posix_time::to_iso_string( *t_ ) : "none" ) << " t: " << boost::posix_time::to_iso_string( t ) << " commit: " << commit << std::endl;
switch( how_ )
{
case first:
if( !t_ ) { t_ = t; }
break;
case last:
if( commit ) { t_ = t; }
break;
case max:
if( !t_ ) { t_ = t; }
if( t_->is_not_a_date_time() ) { break; }
if( t.is_not_a_date_time() ) { t_ = boost::posix_time::not_a_date_time; } else if( *t_ < t ) { t_ = t; }
break;
case mean:
if( t.is_special() || t.is_not_a_date_time() ) { break; }
if( t_ && t_->is_not_a_date_time() ) { break; }
if( t_ ) { ++count_; t_ = *t_ + ( t - *t_ ) / count_; }
else { count_ = 1; t_ = t; }
break;
case middle:
if( !t_ ) { t_ = t; }
if( !commit ) { break; }
if( t.is_special() || t.is_not_a_date_time() ) { t_ = boost::posix_time::not_a_date_time; }
if( !t_->is_not_a_date_time() ) { t_ = *t_ + ( t - *t_ ) / 2; }
break;
case min:
if( !t_ ) { t_ = t; }
if( t_->is_not_a_date_time() ) { break; }
if( t.is_not_a_date_time() ) { t_ = boost::posix_time::not_a_date_time; } else if( *t_ > t ) { t_ = t; }
break;
}
//std::cerr << "--> b: t_: " << ( t_ ? boost::posix_time::to_iso_string( *t_ ) : "none" ) << std::endl << std::endl;
}
示例6: 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);
}
示例7: 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;
}
示例8: 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;
}
示例9: iss
boost::posix_time::ptime FileEndpoint::seek(boost::posix_time::ptime seek){
std::ifstream::pos_type position = 0;
boost::posix_time::ptime timestamp;
try{
in_file_stream.clear();
if(!seek.is_not_a_date_time()){
std::string line;
while(std::getline(in_file_stream, line)){
std::istringstream iss(line);
boost::posix_time::time_input_facet *timefacet = new boost::posix_time::time_input_facet(timestamp_format.c_str());
iss.imbue(std::locale(iss.getloc(), timefacet));
iss >> timestamp;
if(timestamp>seek){
break;
}
position = in_file_stream.tellg();
}
}
in_file_stream.clear();
in_file_stream.seekg(position);
}catch (std::ifstream::failure e){
示例10: invalid_argument
TimeMap::TimeMap(boost::posix_time::ptime startDate) {
if (startDate.is_not_a_date_time())
throw std::invalid_argument("Input argument not properly initialized.");
m_timeList.push_back( boost::posix_time::ptime(startDate) );
}