
On Sun, 26 Mar 2006 19:19:44 +0000 (UTC), george wrote
hello!
boost::gregorian::days size(1);
boost::gregorian::date_period tmp(period.begin()+=size,period.end() -=size);
period=tmp;
is there any better way to increment/decrement the period object
I want period.begin+=size; period.end()-=size
to be permanent to period but it doesn't,it returns an object...
any idea??
No there isn't an easy way to do this in the current release. However, I've checked in a new function to boost/date_time/period.hpp called 'expand' which provides this capability. So you can now say: date_period dp(.....); dp.expand(days(2)); Of course, due to the wonders of generic programming this will now work for time periods too :-) time_period tp(.....); tp.expand(minutes(10)); You can easily patch it in yourself or download a new period.hpp from cvs. Basically in the period.hpp file add this: template<class point_rep, class duration_rep> class period : private //.... void expand(const duration_rep& d); //... Then later in the file /** Expands the size of the period by the duration on both ends. * *So before expand *@code * * [-------] * ^ ^ ^ ^ ^ ^ ^ * 1 2 3 4 5 6 7 * *@endcode * After expand(2) *@code * * [----------------------] * ^ ^ ^ ^ ^ ^ ^ * 1 2 3 4 5 6 7 * *@endcode */ template<class point_rep, class duration_rep> inline void period<point_rep,duration_rep>::expand(const duration_rep& d) { begin_ = begin_ - d; last_ = last_ + d; } Jeff