本文整理汇总了C++中boost::posix_time::ptime::is_infinity方法的典型用法代码示例。如果您正苦于以下问题:C++ ptime::is_infinity方法的具体用法?C++ ptime::is_infinity怎么用?C++ ptime::is_infinity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::posix_time::ptime
的用法示例。
在下文中一共展示了ptime::is_infinity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
}
}