How can you format a boost::posix_time::ptime object without padding the numbers with zeros?
For example, I want to display 6/7/2011 6:30:25 PM
and not 06/07/2011 06:30:25 PM
.
In .NET, the format string would be something like "m/d/yyyy h:mm:ss tt".
Here is some code to do it the wrong way, just to get an idea:
boost::gregorian::date baseDate(1970, 1, 1);
boost::posix_time::ptime shiftDate(baseDate);
boost::posix_time::time_facet *facet = new time_facet("%m/%d/%Y");
cout.imbue(locale(cout.getloc(), facet));
cout << shiftDate;
delete facet;
Output: 01/01/1970