...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::months_duration — additional duration type that represents a logical month
// In header: <boost/date_time/date_duration_types.hpp> template<typename base_config> class months_duration { public: // construct/copy/destruct months_duration(int_rep); months_duration(special_values); // public member functions int_rep number_of_months() const; BOOST_CXX14_CONSTEXPR duration_type get_neg_offset(const date_type &) const; BOOST_CXX14_CONSTEXPR duration_type get_offset(const date_type &) const; BOOST_CONSTEXPR bool operator==(const months_type &) const; BOOST_CONSTEXPR bool operator!=(const months_type &) const; BOOST_CXX14_CONSTEXPR months_type operator+(const months_type &) const; BOOST_CXX14_CONSTEXPR months_type & operator+=(const months_type &); BOOST_CXX14_CONSTEXPR months_type operator-(const months_type &) const; BOOST_CXX14_CONSTEXPR months_type & operator-=(const months_type &); BOOST_CXX14_CONSTEXPR months_type operator *(const int_type) const; BOOST_CXX14_CONSTEXPR months_type & operator *=(const int_type); BOOST_CXX14_CONSTEXPR months_type operator/(const int_type) const; BOOST_CXX14_CONSTEXPR months_type & operator/=(const int_type); BOOST_CXX14_CONSTEXPR months_type operator+(const years_type &) const; BOOST_CXX14_CONSTEXPR months_type & operator+=(const years_type &); BOOST_CXX14_CONSTEXPR months_type operator-(const years_type &) const; BOOST_CXX14_CONSTEXPR months_type & operator-=(const years_type &); };
A logical month enables things like: "date(2002,Mar,2) + months(2) -> 2002-May2". If the date is a last day-of-the-month, the result will also be a last-day-of-the-month.
months_duration
public member functionsint_rep number_of_months() const;
BOOST_CXX14_CONSTEXPR duration_type get_neg_offset(const date_type & d) const;returns a negative duration
BOOST_CXX14_CONSTEXPR duration_type get_offset(const date_type & d) const;
BOOST_CONSTEXPR bool operator==(const months_type & rhs) const;
BOOST_CONSTEXPR bool operator!=(const months_type & rhs) const;
BOOST_CXX14_CONSTEXPR months_type operator+(const months_type & rhs) const;
BOOST_CXX14_CONSTEXPR months_type & operator+=(const months_type & rhs);
BOOST_CXX14_CONSTEXPR months_type operator-(const months_type & rhs) const;
BOOST_CXX14_CONSTEXPR months_type & operator-=(const months_type & rhs);
BOOST_CXX14_CONSTEXPR months_type operator *(const int_type rhs) const;
BOOST_CXX14_CONSTEXPR months_type & operator *=(const int_type rhs);
BOOST_CXX14_CONSTEXPR months_type operator/(const int_type rhs) const;
BOOST_CXX14_CONSTEXPR months_type & operator/=(const int_type rhs);
BOOST_CXX14_CONSTEXPR months_type operator+(const years_type & y) const;
BOOST_CXX14_CONSTEXPR months_type & operator+=(const years_type & y);
BOOST_CXX14_CONSTEXPR months_type operator-(const years_type & y) const;
BOOST_CXX14_CONSTEXPR months_type & operator-=(const years_type & y);