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"> 4 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) 8--> 9 10<section id="date_time.examples.month_add"> 11 <title>Month Adding</title> 12 13 <para> 14 Adding a month to a day without the use of iterators. 15 </para> 16 <programlisting> 17 <![CDATA[ 18 /* Simple program that uses the gregorian calendar to progress by exactly 19 * one month, irregardless of how many days are in that month. 20 * 21 * This method can be used as an alternative to iterators 22 */ 23 24 #include "boost/date_time/gregorian/gregorian.hpp" 25 #include <iostream> 26 27 int 28 main() 29 { 30 31 using namespace boost::gregorian; 32 33 date d = day_clock::local_day(); 34 add_month mf(1); 35 date d2 = d + mf.get_offset(d); 36 std::cout << "Today is: " << to_simple_string(d) << ".\n" 37 << "One month from today will be: " << to_simple_string(d2) 38 << std::endl; 39 40 return 0; 41 } 42 ]]> 43 </programlisting> 44</section> 45