I have a boost::posix_time::ptime
that points to March 31st 2010
like this:
ptime p(date(2010, Mar, 31));
I would like to subtract a month (and possibly years) from this date. From the docs I see these two operators: ptime operator-(time_duration)
and ptime operator-(days)
but none of them can work with months/years. If I try and do:
time_duration duration = hours(24 * 30);
ptime pp = p - duration;
I'm getting March 1st and if I'm trying:
ptime pp = p - days(30);
I'm still getting March 1st, while I'd like to get February 28th.
How can I achieve my desired result? (I would like to get the desired result also when subtracting a month from March 28, 29, 30)