1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <!DOCTYPE library PUBLIC
"-//Boost//DTD BoostBook XML V1.0//EN"
3 "../../../tools/boostbook/dtd/boostbook.dtd">
5 <!-- Copyright (c) 2001-2004 CrystalClear Software, Inc.
6 Subject to the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
10 <section id=
"date_time.examples.end_of_month_day">
11 <title>End of the Months
</title>
14 Iterates accross the remaining months in a given year, always landing on the last day of the month.
18 /* Simple program that uses the gregorian calendar to find the last
19 * day of the month and then display the last day of every month left
23 #include
"boost/date_time/gregorian/gregorian.hpp"
29 using namespace boost::gregorian;
31 std::cout <<
" Enter Year(ex: 2002): ";
34 std::cout <<
" Enter Month(1..12): ";
37 int day = gregorian_calendar::end_of_month_day(year,month);
38 date end_of_month(year,month,day);
40 //Iterate thru by months --
41 month_iterator mitr(end_of_month,
1);
42 date start_of_next_year(year+
1, Jan,
1);
43 //loop thru the days and print each one
44 while (mitr < start_of_next_year){
45 std::cout << to_simple_string(*mitr) << std::endl;
51 std::cout <<
"Invalid Date Entered" << std::endl;