1 // chrono_unit_test.cpp ----------------------------------------------------// 2 3 // Copyright 2008 Beman Dawes 4 5 // Distributed under the Boost Software License, Version 1.0. 6 // See http://www.boost.org/LICENSE_1_0.txt 7 8 #define _CRT_SECURE_NO_WARNINGS // disable VC++ foolishness 9 10 #include <boost/chrono/chrono.hpp> 11 #include <iostream> 12 13 main()14int main() 15 { 16 boost::chrono::nanoseconds nanosecs; 17 boost::chrono::microseconds microsecs; 18 boost::chrono::milliseconds millisecs; 19 boost::chrono::seconds secs; 20 boost::chrono::minutes mins; 21 boost::chrono::hours hrs; 22 23 std::time_t sys_time 24 = boost::chrono::system_clock::to_time_t(boost::chrono::system_clock::now()); 25 26 #ifdef UNDER_CE 27 // Windows CE does not define asctime() 28 struct tm * t = std::gmtime(&sys_time); 29 std::cout 30 << "system_clock::to_time_t(system_clock::now()) is " 31 << t->tm_mon << "/" << t->tm_mday << "/" << (1900 + t->tm_year) << " " << t->tm_hour << ":" << t->tm_min << ":" << t->tm_sec << std::endl; 32 #else 33 std::cout 34 << "system_clock::to_time_t(system_clock::now()) is " 35 << std::asctime(std::gmtime(&sys_time)) << std::endl; 36 #endif 37 38 return 0; 39 } 40