2016-03-03 153 views

回答

3

的最佳選擇是生成正確的字符串開始的,但我不會努力去得到一個「圖書館」要做到這一點,因爲它真的很過分的...

只是這樣的事情

std::string input = "DDMMYY HH:MM"; 

std::string output = input.substr(4, 2) + "-" + // YY- 
        input.substr(2, 2) + "-" + // MM- 
        input.substr(0, 2) +  // DD 
        input.substr(6);   // HH:MM ("the rest") 

把它包裝成一個功能reformat_date有一些解釋第一。

相關問題