Пример #1
0
 //! 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
 static time_rep_type add_time_duration(const time_rep_type& base,
                                        time_duration_type td)
 {
   if(base.is_special() || td.is_special()) {
     return(time_rep_type(base.get_rep() + td.get_rep()));
   }
   else {
     return time_rep_type(base.time_count() + td.ticks());
   }
 }
 static time_rep_type subtract_time_duration(const time_rep_type& base,
                                             const time_duration_type& td)
 {
   if(base.is_special() || td.is_special()) {
     return(time_rep_type(base.get_rep() - td.get_rep()));
   }
   else {
     return time_rep_type(base.time_count() - td.ticks());
   }
 }
 counted_time_rep(const date_type& d, const time_duration_type& time_of_day) 
   : time_count_(1)
 {
   if(d.is_infinity() || d.is_not_a_date() || time_of_day.is_special()) {
     time_count_ = time_of_day.get_rep() + d.day_count();
     //std::cout << time_count_ << std::endl;
   }
   else {    
     time_count_ = (d.day_number() * frac_sec_per_day()) + time_of_day.ticks();
   }
 }