...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::years_duration — additional duration type that represents a logical year
// In header: <boost/date_time/date_duration_types.hpp> template<typename base_config> class years_duration { public: // public member functions years_duration(int_rep); years_duration(special_values); BOOST_CXX14_CONSTEXPR int_rep number_of_years() 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_CXX14_CONSTEXPR bool operator==(const years_type &) const; bool operator!=(const years_type &) const; BOOST_CXX14_CONSTEXPR years_type operator+(const years_type &) const; BOOST_CXX14_CONSTEXPR years_type & operator+=(const years_type &); BOOST_CXX14_CONSTEXPR years_type operator-(const years_type &) const; BOOST_CXX14_CONSTEXPR years_type & operator-=(const years_type &); BOOST_CXX14_CONSTEXPR years_type operator*(const int_type) const; BOOST_CXX14_CONSTEXPR years_type & operator*=(const int_type); BOOST_CXX14_CONSTEXPR years_type operator/(const int_type) const; BOOST_CXX14_CONSTEXPR years_type & operator/=(const int_type); BOOST_CXX14_CONSTEXPR months_type operator+(const months_type &) const; BOOST_CXX14_CONSTEXPR months_type operator-(const months_type &) const; };
A logical year enables things like: "date(2002,Mar,2) + years(2) -> 2004-Mar-2". If the date is a last day-of-the-month, the result will also be a last-day-of-the-month (ie date(2001-Feb-28) + years(3) -> 2004-Feb-29).
years_duration
public member functionsyears_duration(int_rep num);
years_duration(special_values sv);
BOOST_CXX14_CONSTEXPR int_rep number_of_years() 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_CXX14_CONSTEXPR bool operator==(const years_type & rhs) const;
bool operator!=(const years_type & rhs) const;
BOOST_CXX14_CONSTEXPR years_type operator+(const years_type & rhs) const;
BOOST_CXX14_CONSTEXPR years_type & operator+=(const years_type & rhs);
BOOST_CXX14_CONSTEXPR years_type operator-(const years_type & rhs) const;
BOOST_CXX14_CONSTEXPR years_type & operator-=(const years_type & rhs);
BOOST_CXX14_CONSTEXPR years_type operator*(const int_type rhs) const;
BOOST_CXX14_CONSTEXPR years_type & operator*=(const int_type rhs);
BOOST_CXX14_CONSTEXPR years_type operator/(const int_type rhs) const;
BOOST_CXX14_CONSTEXPR years_type & operator/=(const int_type rhs);
BOOST_CXX14_CONSTEXPR months_type operator+(const months_type & m) const;
BOOST_CXX14_CONSTEXPR months_type operator-(const months_type & m) const;