testclocks.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* Copyright (c) 2003-2004 CrystalClear Software, Inc.
  2. * Subject to the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  4. * Author: Jeff Garland, Bart Garst
  5. * $Date$
  6. */
  7. #include "boost/date_time/local_time/local_time.hpp"
  8. #include <iostream>
  9. // The actual clocks are tested in posix_time/testclock.cpp.
  10. // These tests are to verify that the time zone is applied correctly
  11. int
  12. main()
  13. {
  14. using namespace boost::gregorian;
  15. using namespace boost::posix_time;
  16. using namespace boost::local_time;
  17. boost::shared_ptr<time_zone> az_tz(new posix_time_zone("MST-07"));
  18. boost::shared_ptr<time_zone> ny_tz(new posix_time_zone("EST-05EDT,M4.1.0,M10.5.0"));
  19. ptime tl = second_clock::local_time();
  20. std::cout << to_simple_string(tl) << std::endl;
  21. local_date_time ldt1 = local_sec_clock::local_time(az_tz);
  22. std::cout << ldt1.to_string() << std::endl;
  23. local_date_time ldt2 = local_sec_clock::local_time(ny_tz);
  24. std::cout << ldt2.to_string() << std::endl;
  25. tl = microsec_clock::local_time();
  26. std::cout << to_simple_string(tl) << std::endl;
  27. local_date_time ldt3 = local_microsec_clock::local_time(az_tz);
  28. std::cout << ldt3.to_string() << std::endl;
  29. local_date_time ldt4 = local_microsec_clock::local_time(ny_tz);
  30. std::cout << ldt4.to_string() << std::endl;
  31. return 0;
  32. }