2012-02-06 2 views
0

나는 부스트 :: posix_time에 문제가 예. "08 : 15 : 30.093750". 맞습니다. 정확히 내가 기대하는 것. 하지만 때로는 이상하게 보았습니다. "08 : 15 : 32.000000"대신 "08:15:32". "08 : 15 : 32.000000"을 얻는 방법?고정 정밀 ::의 Ptime

미리 감사드립니다.

솔루션 :

std::wstringstream record; 
boost::date_time::time_facet<boost::posix_time::ptime, wchar_t>* timeFacet(new boost::date_time::time_facet<boost::posix_time::ptime, wchar_t>(L"%f")); 
record.imbue(std::locale(record.getloc(), timeFacet)); 
record << now.time_of_day(); 

답변

0

hours, minutes, and seconds 접근을 사용하지만 원하는 출력 형식. 당신이 기본이 아닌 서식을 원하는 경우

2
+1

그것은 작동 : '표준 : wstringstream 기록을,' 은'부스트 : DATE_TIME :: time_facet <부스트 : posix_time를 : : ptime, wchar_t> * timeFacet (새로운 boost :: date_time :: time_facet (L "% f")); ' 'record.imbue (std :: locale (record. 'record

+0

@PetervanderSanden : 좀 더 짧게하기 위해 typedef'boost :: posix_time :: time_facet'을 사용할 수도 있습니다 (그리고 getloc(), timeFacet)). 아마도 더 강력 할 것이다). – foraidt