chrono

 

 

  •  将毫秒转换为时分秒毫秒表示
using namespace std;
using namespace std::chrono;
milliseconds ms(7255042);

// split into hours, minutes, seconds, and milliseconds
hours   hh         = duration_cast<hours>(ms);
minutes mm        = duration_cast<minutes>(ms % chrono::hours(1));
seconds ss         = duration_cast<seconds>(ms % chrono::minutes(1));
milliseconds msec  = duration_cast<milliseconds>(ms % chrono::seconds(1));

// and print durations and values:
cout << "raw: " << hh << "::" << mm << "::"
                << ss << "::" << msec << endl;
cout << "     " << setfill(’0’) << setw(2) << hh.count() << "::"
                                << setw(2) << mm.count() << "::"
                                << setw(2) << ss.count() << "::"
                                << setw(3) << msec.count() << endl;            
raw: [2 of 3600/1]::[0 of 60/1]::[55 of 1/1]::[42 of 1/1000] 02::00::55::042

 

posted @ 2016-06-23 09:08  fndefbwefsowpvqfx  阅读(275)  评论(0编辑  收藏  举报