...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::date_time::time_duration — Represents some amount of elapsed time measure to a given resolution.
// In header: <boost/date_time/time_duration.hpp> template<typename T, typename rep_type> class time_duration { public: // types typedef T duration_type; typedef rep_type traits_type; typedef rep_type::day_type day_type; typedef rep_type::hour_type hour_type; typedef rep_type::min_type min_type; typedef rep_type::sec_type sec_type; typedef rep_type::fractional_seconds_type fractional_seconds_type; typedef rep_type::tick_type tick_type; typedef rep_type::impl_type impl_type; // construct/copy/destruct time_duration(); time_duration(hour_type, min_type, sec_type = 0, fractional_seconds_type = 0); time_duration(const time_duration< T, rep_type > &); time_duration(special_values); time_duration(impl_type); // public member functions hour_type hours() const; min_type minutes() const; sec_type seconds() const; sec_type total_seconds() const; tick_type total_milliseconds() const; tick_type total_nanoseconds() const; tick_type total_microseconds() const; fractional_seconds_type fractional_seconds() const; duration_type invert_sign() const; bool is_negative() const; bool operator<(const time_duration &) const; bool operator==(const time_duration &) const; duration_type operator-() const; duration_type operator-(const duration_type &) const; duration_type operator+(const duration_type &) const; duration_type operator/(int) const; duration_type operator-=(const duration_type &) ; duration_type operator+=(const duration_type &) ; duration_type operator/=(int) ; duration_type operator*(int) const; duration_type operator*=(int) ; tick_type ticks() const; bool is_special() const; bool is_pos_infinity() const; bool is_neg_infinity() const; bool is_not_a_date_time() const; impl_type get_rep() const; // public static functions static duration_type unit() ; static tick_type ticks_per_second() ; static time_resolutions resolution() ; static unsigned short num_fractional_digits() ; };
This class represents a standard set of capabilities for all counted time durations. Time duration implementations should derive from this class passing their type as the first template parameter. This design allows the subclass duration types to provide custom construction policies or other custom features not provided here.
time_duration
public
construct/copy/destructtime_duration();
time_duration(hour_type hours_in, min_type minutes_in, sec_type seconds_in = 0, fractional_seconds_type frac_sec_in = 0);
time_duration(const time_duration< T, rep_type > & other);
time_duration(special_values sv);
time_duration(impl_type in);
time_duration
public member functionshour_type hours() const;
min_type minutes() const;
sec_type seconds() const;
sec_type total_seconds() const;
tick_type total_milliseconds() const;
tick_type total_nanoseconds() const;
tick_type total_microseconds() const;
fractional_seconds_type fractional_seconds() const;
duration_type invert_sign() const;
bool is_negative() const;
bool operator<(const time_duration & rhs) const;
bool operator==(const time_duration & rhs) const;
duration_type operator-() const;
duration_type operator-(const duration_type & d) const;
duration_type operator+(const duration_type & d) const;
duration_type operator/(int divisor) const;
duration_type operator-=(const duration_type & d) ;
duration_type operator+=(const duration_type & d) ;
duration_type operator/=(int divisor) ;
duration_type operator*(int rhs) const;
duration_type operator*=(int divisor) ;
tick_type ticks() const;
bool is_special() const;
bool is_pos_infinity() const;
bool is_neg_infinity() const;
bool is_not_a_date_time() const;
impl_type get_rep() const;