1 /* Simple program that uses the gregorian calendar to find the last
2  * day of the month and then display the last day of every month left
3  * in the year.
4  */
5 
6 #include "boost/date_time/gregorian/gregorian.hpp"
7 #include <iostream>
8 
9 int
main()10 main()
11 {
12   using namespace boost::gregorian;
13 
14   std::cout << "   Enter Year(ex: 2002): ";
15   int year, month;
16   std::cin >> year;
17   std::cout << "   Enter Month(1..12): ";
18   std::cin >> month;
19   try {
20     int day = gregorian_calendar::end_of_month_day(year,month);
21     date end_of_month(year,month,day);
22 
23     //Iterate thru by months --
24     month_iterator mitr(end_of_month,1);
25     date start_of_next_year(year+1, Jan, 1);
26     //loop thru the days and print each one
27     while (mitr < start_of_next_year){
28       std::cout << to_simple_string(*mitr) << std::endl;
29       ++mitr;
30     }
31 
32   }
33   catch(...) {
34     std::cout << "Invalid Date Entered" << std::endl;
35   }
36   return 0;
37 
38 }
39 
40 /*  Copyright 2001-2004: CrystalClear Software, Inc
41  *  http://www.crystalclearsoftware.com
42  *
43  *  Subject to the Boost Software License, Version 1.0.
44  * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
45  */
46 
47