...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; duration_type get_neg_offset(const date_type &) const; duration_type get_offset(const date_type &) const; bool operator==(const months_type &) const; bool operator!=(const months_type &) const; months_type operator+(const months_type &) const; months_type & operator+=(const months_type &) ; months_type operator-(const months_type &) const; months_type & operator-=(const months_type &) ; months_type operator*(const int_type) const; months_type & operator*=(const int_type) ; months_type operator/(const int_type) const; months_type & operator/=(const int_type) ; months_type operator+(const years_type &) const; months_type & operator+=(const years_type &) ; months_type operator-(const years_type &) const; 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;
duration_type get_neg_offset(const date_type & d) const;returns a negative duration
duration_type get_offset(const date_type & d) const;
bool operator==(const months_type & rhs) const;
bool operator!=(const months_type & rhs) const;
months_type operator+(const months_type & rhs) const;
months_type & operator+=(const months_type & rhs) ;
months_type operator-(const months_type & rhs) const;
months_type & operator-=(const months_type & rhs) ;
months_type operator*(const int_type rhs) const;
months_type & operator*=(const int_type rhs) ;
months_type operator/(const int_type rhs) const;
months_type & operator/=(const int_type rhs) ;
months_type operator+(const years_type & y) const;
months_type & operator+=(const years_type & y) ;
months_type operator-(const years_type & y) const;
months_type & operator-=(const years_type & y) ;