chrono_unit_test.cpp 936 B

1234567891011121314151617181920212223242526272829303132
  1. // chrono_unit_test.cpp ----------------------------------------------------//
  2. // Copyright 2008 Beman Dawes
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // See http://www.boost.org/LICENSE_1_0.txt
  5. #define _CRT_SECURE_NO_WARNINGS // disable VC++ foolishness
  6. #include <boost/chrono/chrono.hpp>
  7. #include <iostream>
  8. int main()
  9. {
  10. std::time_t sys_time
  11. = boost::chrono::system_clock::to_time_t(boost::chrono::system_clock::now());
  12. #ifdef UNDER_CE
  13. // Windows CE does not define asctime()
  14. struct tm * t = std::gmtime(&sys_time);
  15. std::cout
  16. << "system_clock::to_time_t(system_clock::now()) is "
  17. << t->tm_mon << "/" << t->tm_mday << "/" << (1900 + t->tm_year) << " " << t->tm_hour << ":" << t->tm_min << ":" << t->tm_sec << std::endl;
  18. #else
  19. std::cout
  20. << "system_clock::to_time_t(system_clock::now()) is "
  21. << std::asctime(std::gmtime(&sys_time)) << std::endl;
  22. #endif
  23. return 0;
  24. }