| 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 | |
| 14 | int main() |
| 15 | { |
| 16 | std::time_t sys_time |
| 17 | = boost::chrono::system_clock::to_time_t(t: boost::chrono::system_clock::now()); |
| 18 | |
| 19 | #ifdef UNDER_CE |
| 20 | // Windows CE does not define asctime() |
| 21 | struct tm * t = std::gmtime(&sys_time); |
| 22 | std::cout |
| 23 | << "system_clock::to_time_t(system_clock::now()) is " |
| 24 | << t->tm_mon << "/" << t->tm_mday << "/" << (1900 + t->tm_year) << " " << t->tm_hour << ":" << t->tm_min << ":" << t->tm_sec << std::endl; |
| 25 | #else |
| 26 | std::cout |
| 27 | << "system_clock::to_time_t(system_clock::now()) is " |
| 28 | << std::asctime(tp: std::gmtime(timer: &sys_time)) << std::endl; |
| 29 | #endif |
| 30 | |
| 31 | return 0; |
| 32 | } |
| 33 | |