...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::date_duration — Duration type with date level resolution.
// In header: <boost/date_time/date_duration.hpp> template<typename duration_rep_traits> class date_duration : private boost::less_than_comparable1< date_duration< duration_rep_traits >, boost::equality_comparable1< date_duration< duration_rep_traits >, boost::addable1< date_duration< duration_rep_traits >, boost::subtractable1< date_duration< duration_rep_traits >, boost::dividable2< date_duration< duration_rep_traits >, int > > > > > { public: // types typedef duration_rep_traits::int_type duration_rep_type; typedef duration_rep_traits::impl_type duration_rep; // construct/copy/destruct explicit date_duration(duration_rep); date_duration(special_values); // public member functions BOOST_CXX14_CONSTEXPR duration_rep get_rep() const; BOOST_CXX14_CONSTEXPR special_values as_special() const; BOOST_CXX14_CONSTEXPR bool is_special() const; BOOST_CXX14_CONSTEXPR duration_rep_type days() const; BOOST_CXX14_CONSTEXPR bool operator==(const date_duration &) const; BOOST_CXX14_CONSTEXPR bool operator<(const date_duration &) const; BOOST_CXX14_CONSTEXPR date_duration & operator-=(const date_duration &); BOOST_CXX14_CONSTEXPR date_duration & operator+=(const date_duration &); BOOST_CXX14_CONSTEXPR date_duration operator-() const; BOOST_CXX14_CONSTEXPR date_duration & operator/=(int); BOOST_CXX14_CONSTEXPR bool is_negative() const; // public static functions static BOOST_CXX14_CONSTEXPR date_duration unit(); };
date_duration
public
construct/copy/destructexplicit date_duration(duration_rep day_count);Construct from a day count.
date_duration(special_values sv);
construct from special_values - only works when instantiated with duration_traits_adapted
date_duration
public member functionsBOOST_CXX14_CONSTEXPR duration_rep get_rep() const;returns days_ as it's instantiated type - used for streaming
BOOST_CXX14_CONSTEXPR special_values as_special() const;
BOOST_CXX14_CONSTEXPR bool is_special() const;
BOOST_CXX14_CONSTEXPR duration_rep_type days() const;returns days as value, not object.
BOOST_CXX14_CONSTEXPR bool operator==(const date_duration & rhs) const;Equality.
BOOST_CXX14_CONSTEXPR bool operator<(const date_duration & rhs) const;Less.
BOOST_CXX14_CONSTEXPR date_duration & operator-=(const date_duration & rhs);Subtract another duration – result is signed.
BOOST_CXX14_CONSTEXPR date_duration & operator+=(const date_duration & rhs);Add a duration – result is signed.
BOOST_CXX14_CONSTEXPR date_duration operator-() const;unary- Allows for dd = -date_duration(2); -> dd == -2
BOOST_CXX14_CONSTEXPR date_duration & operator/=(int divisor);Division operations on a duration with an integer.
BOOST_CXX14_CONSTEXPR bool is_negative() const;return sign information
date_duration
public static functionsstatic BOOST_CXX14_CONSTEXPR date_duration unit();Returns the smallest duration – used by to calculate 'end'.