本文整理汇总了C++中boost::posix_time::time_duration::hours方法的典型用法代码示例。如果您正苦于以下问题:C++ time_duration::hours方法的具体用法?C++ time_duration::hours怎么用?C++ time_duration::hours使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::posix_time::time_duration
的用法示例。
在下文中一共展示了time_duration::hours方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
boost::posix_time::time_duration Service::GetTimeOfDay( const boost::posix_time::time_duration& value )
{
return
value >= DAY_DURATION ?
time_duration(value.hours() % 24, value.minutes(), value.seconds()) :
value
;
}
示例2: to_tm
//! Convert a time_duration to a tm structure truncating any fractional seconds and zeroing fields for date components
inline
std::tm to_tm(const boost::posix_time::time_duration& td) {
std::tm timetm = {};
timetm.tm_hour = date_time::absolute_value(td.hours());
timetm.tm_min = date_time::absolute_value(td.minutes());
timetm.tm_sec = date_time::absolute_value(td.seconds());
timetm.tm_isdst = -1; // -1 used when dst info is unknown
return timetm;
}
示例3: durationToStr
std::string durationToStr(const boost::posix_time::time_duration &duration)
{
std::stringstream ss;
ss << std::setfill('0') << std::setw(2) << duration.hours() << ":"
<< std::setfill('0') << std::setw(2) << duration.minutes() << ":"
<< std::setfill('0') << std::setw(2) << duration.seconds();
return ss.str();
}
示例4: to_tm
//! Convert a time_duration to a tm structure truncating any fractional seconds and zeroing fields for date components
inline
std::tm to_tm(const boost::posix_time::time_duration& td) {
std::tm timetm;
std::memset(&timetm, 0, sizeof(timetm));
timetm.tm_hour = static_cast<int>(date_time::absolute_value(td.hours()));
timetm.tm_min = static_cast<int>(date_time::absolute_value(td.minutes()));
timetm.tm_sec = static_cast<int>(date_time::absolute_value(td.seconds()));
timetm.tm_isdst = -1; // -1 used when dst info is unknown
return timetm;
}
示例5: EncodeSchedule
std::string SchedulesBasedService::EncodeSchedule( const boost::posix_time::time_duration& value )
{
if(value.is_not_a_date_time())
{
return string();
}
std::stringstream os;
os << std::setw( 2 ) << std::setfill ( '0' )
<< (value.hours() / 24) << ":"
<< std::setw( 2 ) << std::setfill ( '0' )
<< (value.hours() % 24) << ":"
<< std::setw( 2 ) << std::setfill ( '0' )
<< value.minutes()
;
return os.str ();
}
示例6: current_time_string
string current_time_string() {
stringstream sstream;
boost::posix_time::ptime now = boost::posix_time::
microsec_clock::local_time();
const boost::posix_time::time_duration td = now.time_of_day();
const long hours = td.hours();
const long minutes = td.minutes();
const long seconds = td.seconds();
const long milliseconds = td.total_milliseconds() -
((hours * 3600 + minutes * 60 + seconds) *
1000);
char buf[40];
sprintf(buf, "%02ld:%02ld:%02ld.%03ld",
hours, minutes, seconds, milliseconds);
return string(buf);
}