From e2fb13a35008d76f9dbdb286bc516203e5142a9e Mon Sep 17 00:00:00 2001 From: Jeff Garland Date: Sun, 18 Apr 2004 19:35:25 +0000 Subject: [PATCH] fix for feb29th corner case with year_iterator [SVN r22659] --- include/boost/date_time/adjust_functors.hpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/include/boost/date_time/adjust_functors.hpp b/include/boost/date_time/adjust_functors.hpp index 0e94a89..dbebf02 100644 --- a/include/boost/date_time/adjust_functors.hpp +++ b/include/boost/date_time/adjust_functors.hpp @@ -151,9 +151,6 @@ namespace date_time { }; //! Functor to iterate by a year adjusting for leap years - /*! - *@throws bad_day if date value is invalid (eg: feb 29) - */ template class year_functor { @@ -163,20 +160,17 @@ namespace date_time { year_functor(int f) : f_(f) {} duration_type get_offset(const date_type& d) const { - year_type y = static_cast(d.year()+f_); - date_type new_date(y, d.month(), d.day()); - return new_date-d; + month_functor mf(f_ * 12); + return mf.get_offset(d); } duration_type get_neg_offset(const date_type& d) const { - year_type y = static_cast(d.year()-f_); - date_type new_date(y, d.month(), d.day()); - return new_date-d; + month_functor mf(f_ * 12); + return mf.get_neg_offset(d); } private: int f_; }; - } }//namespace date_time