]>
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
18 greg_year::value_type y
;
19 greg_month::value_type m
;
20 std::cout
<< " Enter Year(ex: 2002): ";
23 std::cout
<< " Enter Month(1..12): ";
25 month
= greg_month(m
);
27 catch(const bad_year
& by
) {
28 std::cout
<< "Invalid Year Entered: " << by
.what() << '\n'
29 << "Using minimum values for month and year." << std::endl
;
31 catch(const bad_month
& bm
) {
32 std::cout
<< "Invalid Month Entered" << bm
.what() << '\n'
33 << "Using minimum value for month. " << std::endl
;
36 date
start_of_next_year(year
+1, Jan
, 1);
37 date
d(year
, month
, 1);
39 // add another month to d until we enter the next year.
40 while (d
< start_of_next_year
){
41 std::cout
<< to_simple_string(d
.end_of_month()) << std::endl
;
48 /* Copyright 2001-2005: CrystalClear Software, Inc
49 * http://www.crystalclearsoftware.com
51 * Subject to the Boost Software License, Version 1.0.
52 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)