testcurrent_day.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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/date_time/gregorian/gregorian.hpp"
  8. #include <iostream>
  9. int
  10. main()
  11. {
  12. boost::gregorian::date d1(boost::gregorian::day_clock::local_day());
  13. std::cout << "Check the printed date by hand: "
  14. << boost::gregorian::to_iso_string(d1) << std::endl;
  15. using namespace boost::gregorian;
  16. date::ymd_type ymd = day_clock::local_day_ymd();
  17. std::cout << ymd.year << "-"
  18. << ymd.month.as_long_string() << "-"
  19. << ymd.day << std::endl;
  20. date d2(day_clock::universal_day());
  21. std::cout << "Getting UTC date: "
  22. << to_iso_string(d2) << std::endl;
  23. date::ymd_type ymd2 = day_clock::universal_day_ymd();
  24. std::cout << ymd2.year << "-"
  25. << ymd2.month.as_long_string() << "-"
  26. << ymd2.day << std::endl;
  27. return 0;
  28. }