days_since_year_start.cpp 630 B

12345678910111213141516171819202122232425
  1. #include "boost/date_time/gregorian/gregorian.hpp"
  2. #include <iostream>
  3. int
  4. main()
  5. {
  6. using namespace boost::gregorian;
  7. date today = day_clock::local_day();
  8. //Subtract two dates to get a duration
  9. date_duration days_since_year_start = today - date(today.year(),Jan,1);
  10. std::cout << "Days since Jan 1: " << days_since_year_start.days()
  11. << std::endl;
  12. return 0;
  13. }
  14. /* Copyright 2001-2004: CrystalClear Software, Inc
  15. * http://www.crystalclearsoftware.com
  16. *
  17. * Subject to the Boost Software License, Version 1.0.
  18. * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  19. */