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


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

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


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

示例1: 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

示例2: now

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

示例3: 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;
 }
开发者ID:acfr,项目名称:snark,代码行数:36,代码来源:image-from-csv.cpp

示例4:

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


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