]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/date_time/example/gregorian/find_last_day_of_months.cpp
1 /* Simple program that finds the last day of the given month,
2 * then displays the last day of every month left in the given year.
5 #include "boost/date_time/gregorian/gregorian.hpp"
11 using namespace boost::gregorian
;
16 // get a month and a year from the user
19 std::cout
<< " Enter Year(ex: 2002): ";
22 std::cout
<< " Enter Month(1..12): ";
24 month
= greg_month(m
);
27 std::cout
<< "Invalid Year Entered: " << by
.what() << '\n'
28 << "Using minimum values for month and year." << std::endl
;
31 std::cout
<< "Invalid Month Entered" << bm
.what() << '\n'
32 << "Using minimum value for month. " << std::endl
;
35 date
start_of_next_year(year
+1, Jan
, 1);
36 date
d(year
, month
, 1);
38 // add another month to d until we enter the next year.
39 while (d
< start_of_next_year
){
40 std::cout
<< to_simple_string(d
.end_of_month()) << std::endl
;
47 /* Copyright 2001-2005: CrystalClear Software, Inc
48 * http://www.crystalclearsoftware.com
50 * Subject to the Boost Software License, Version 1.0.
51 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)