本文整理汇总了C++中time_duration_type::is_negative方法的典型用法代码示例。如果您正苦于以下问题:C++ time_duration_type::is_negative方法的具体用法?C++ time_duration_type::is_negative怎么用?C++ time_duration_type::is_negative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类time_duration_type
的用法示例。
在下文中一共展示了time_duration_type::is_negative方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: duration_put
//! Put time into an ostream
static void duration_put(const time_duration_type& td,
ostream_type& os)
{
if(td.is_special()) {
os << td.get_rep();
}
else {
charT fill_char = '0';
if(td.is_negative()) {
os << '-';
}
os << std::setw(2) << std::setfill(fill_char)
<< absolute_value(td.hours()) << ":";
os << std::setw(2) << std::setfill(fill_char)
<< absolute_value(td.minutes()) << ":";
os << std::setw(2) << std::setfill(fill_char)
<< absolute_value(td.seconds());
fractional_seconds_type frac_sec =
absolute_value(td.fractional_seconds());
if (frac_sec != 0) {
os << "."
<< std::setw(time_duration_type::num_fractional_digits())
<< std::setfill(fill_char)
<< frac_sec;
}
} // else
} // duration_put
示例2: add_time_duration
static time_rep_type add_time_duration(const time_rep_type& base,
time_duration_type td)
{
if(base.day.is_special() || td.is_special()) {
return split_timedate_system::get_time_rep(base.day, td);
}
if (td.is_negative()) {
time_duration_type td1 = td.invert_sign();
return subtract_time_duration(base,td1);
}
wrap_int_type day_offset(base.time_of_day.ticks());
date_duration_type day_overflow(static_cast< typename date_duration_type::duration_rep_type >(day_offset.add(td.ticks())));
return time_rep_type(base.day+day_overflow,
time_duration_type(0,0,0,day_offset.as_int()));
}
示例3: add_time_duration
static time_rep_type add_time_duration(const time_rep_type& base,
time_duration_type td)
{
if(base.day.is_special() || td.is_special()) {
return split_timedate_system::get_time_rep(base.day, td);
}
if (td.is_negative()) {
time_duration_type td1 = td.invert_sign();
return subtract_time_duration(base,td1);
}
wrap_int_type day_offset(base.time_of_day.ticks());
int_type doff = day_offset.add(td.ticks());
// std::cout << "day overflow: " << doff << std::endl;
// std::cout << "ticks: " << td.ticks() << std::endl;
date_duration_type day_overflow(static_cast<int_type>(doff));
// std::cout << "base: " << to_simple_string(base.day) << std::endl;
// std::cout << "overflow " << day_overflow.days() << std::endl;
return time_rep_type(base.day+day_overflow,
time_duration_type(0,0,0,day_offset.as_int()));
}
示例4: subtract_time_duration
static time_rep_type subtract_time_duration(const time_rep_type& base,
const time_duration_type& td)
{
if(base.day.is_special() || td.is_special())
{
return split_timedate_system::get_time_rep(base.day, -td);
}
if (td.is_negative()) {
time_duration_type td1 = td.invert_sign();
return add_time_duration(base,td1);
}
//std::cout << td.ticks() << std::endl;
wrap_int_type day_offset(base.time_of_day.ticks());
date_duration_type day_overflow(static_cast<int_type>(day_offset.subtract(td.ticks())));
// std::cout << "sub: " << base.time_of_day.ticks() << "|"
// << day_offset.as_int() << "|"
// << day_overflow.days() << std::endl;
return time_rep_type(base.day-day_overflow,
time_duration_type(0,0,0,day_offset.as_int()));
}