testclock.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
  2. * Use, modification and distribution is subject to the
  3. * Boost Software License, Version 1.0. (See accompanying
  4. * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  5. * Author: Jeff Garland
  6. */
  7. #include <boost/config.hpp>
  8. #include "boost/date_time/posix_time/posix_time.hpp"
  9. #include <iostream>
  10. int
  11. main()
  12. {
  13. using namespace boost::posix_time;
  14. ptime tl = second_clock::local_time();
  15. std::cout << to_simple_string(tl) << std::endl;
  16. ptime tu = second_clock::universal_time();
  17. std::cout << to_simple_string(tu) << std::endl;
  18. #if !defined(BOOST_WINDOWS) && defined(_POSIX_TIMERS)
  19. for (int i=0; i < 3; ++i) {
  20. ptime t2 = second_clock::local_time();
  21. std::cout << to_simple_string(t2) << std::endl;
  22. sleep(1);
  23. }
  24. #endif
  25. #ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
  26. for (int i=0; i < 10; ++i) {
  27. //ptime t2 = high_precision_clock::local_time();
  28. ptime t2 = microsec_clock::local_time();
  29. std::cout << to_simple_string(t2) << std::endl;
  30. }
  31. #endif // BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
  32. return 0;
  33. }