I need to be able to convert and compare dates in C ++. I found that the acceleration library pretty much fits my needs, but I can't get it to work correctly:
// include headers... using namespace boost::posix_time; using namespace boost::gregorian; ptime p1(second_clock::universal_time()); p1 -= weeks(5); // Subtract 5 weeks from p1 using boost... std::string old_date("2011-11-19"); // format:YYYY-MM-DD std:stringstream ss(old_date); ptime p2; p2 << ss; if(p1 <= p2){ // this should not happen in this case (yet it does!) p1 > p2!! }
Basically, I want to subtract the weeks (or months) of the local date, and then compare the result with the date specified as a string in the format YYYY-MM-DD ...
source share