days_till_new_year.cpp 663 B

1234567891011121314151617181920212223242526
  1. // This example displays the amount of time until new year's in days
  2. #include "boost/date_time/gregorian/gregorian.hpp"
  3. #include <iostream>
  4. int
  5. main()
  6. {
  7. using namespace boost::gregorian;
  8. date::ymd_type today = day_clock::local_day_ymd();
  9. date new_years_day(today.year + 1,1,1);
  10. date_duration dd = new_years_day - date(today);
  11. std::cout << "Days till new year: " << dd.days() << 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. */