Format local time in W3C format (YYYY-MM-DDThh:mm:ss.sTZD) without providing the time zone myself?
I'm having trouble in formatting the local time in W3C format. The format is described at http://www.w3.org/TR/NOTE-datetime as follows:
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
My first attempt was to use a ptime as follows:
boost::posix_time::ptime t(boost::posix_time::microsec_clock::local_time());
boost::posix_time::time_facet* output_facet = new boost::posix_time::time_facet();
ss.imbue(std::locale(std::locale::classic(), output_facet));
output_facet->format("%Y-%m-%dT%H:%M:%S%f%Q");
ss << t;
But when using a ptime in combination with a time_facet, the time zone (%Q) is ignored (also mentioned in the documentation http://www.boost.org/doc/libs/1_34_1/doc/html/date_time/date_time_io.html)
So i thought to switch to the local time library which gives me the following code:
typedef boost::date_time::time_facet
participants (1)
-
Paul Bormans