Using timelines in universal_time

in boost, to create a time facet to format the specified time, we use the following:

boost::local_time::local_time_facet* facet = new boost::local_time::local_time_facet("%Y%m%d %H:%M:%S.%f"); std::stringstream date_stream; date_stream.imbue(std::locale(date_stream.getloc(), facet)); date_stream << boost::local_time::local_microsec_clock::local_time(boost::local_time::time_zone_ptr()); 

How can I do the same, but using a universal watch:

 boost::posix_time::microsec_clock::universal_time() 

thanks

+4
source share
1 answer

I know that by now scooterman has either found the answer or is no longer interested in (: D), but in case someone found this question during the search (for example, I did), here is the answer:

 boost::posix_time::ptime time(microsec_clock::universal_time()); std::stringstream ss; boost::date_time::time_facet *facetPtr = new boost::date_time::time_facet("%a, %d %b %Y %H:%M:%S.%f GMT"); ss.imbue(std::locale(ss.getloc(), facetPtr)); ss << time; //ss.str() contains the formatted time string 
+4
source

Source: https://habr.com/ru/post/1305103/


All Articles