C++ examples for Data Type:time
Three Techniques for Creating a chrono::duration
#include <iostream> #include <chrono> using namespace std; chrono::duration<unsigned long long> operator"" _m(unsigned long long Value) { return chrono::duration<int, ratio<60>>(Value); } int main()/*from w w w .j av a 2 s . c o m*/ { typedef chrono::duration<double, ratio<1, 5>> fifths; // Define an interval of 20 minutes. chrono::duration<int, ratio<60>>StdTime(20); auto AutoTime(20_m); auto UDLTime(20min); // Output the time in seconds. cout << chrono::duration_cast<chrono::seconds>(StdTime).count() << endl; cout << chrono::duration_cast<chrono::seconds>(AutoTime).count() << endl; cout << chrono::duration_cast<chrono::seconds>(UDLTime).count() << endl; return 0; }