mirror of
https://github.com/boostorg/date_time.git
synced 2026-02-23 03:32:16 +00:00
73 lines
2.7 KiB
XML
73 lines
2.7 KiB
XML
<section id="date_time.gregorian.date_iterators">
|
|
<title>Date Iterators</title>
|
|
|
|
<link linkend="iterators_intro">Introduction</link> --
|
|
<link linkend="iterators_header">Header</link> --
|
|
<link linkend="iterators_overview">Overview</link>
|
|
|
|
<anchor id="iterators_intro" />
|
|
<bridgehead renderas="sect3">Introduction</bridgehead>
|
|
<para>
|
|
Date iterators provide a standard mechanism for iteration through dates. Date iterators are a model of <ulink url="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</ulink> and can be used to populate collections with dates and other date generation tasks. For example, the <link linkend="date_time.examples.print_month">print month</link> example iterates through all the days in a month and prints them.
|
|
</para>
|
|
<para>
|
|
All of the iterators here derive from boost::gregorian::date_iterator.
|
|
</para>
|
|
|
|
<anchor id="iterators_header" />
|
|
<bridgehead renderas="sect3">Header</bridgehead>
|
|
<para>
|
|
<programlisting>
|
|
#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
|
|
or
|
|
#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
|
|
</programlisting>
|
|
</para>
|
|
|
|
<anchor id="iterators_overview" />
|
|
<bridgehead renderas="sect3">Overview</bridgehead>
|
|
<informaltable frame="all">
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row>
|
|
<entry>Class</entry>
|
|
<entry>Construction Parameters</entry>
|
|
<entry>Description</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>date_iterator</entry>
|
|
<entry></entry>
|
|
<entry>Common base class for all day level iterators.</entry>
|
|
</row>
|
|
<row>
|
|
<entry>day_iterator</entry>
|
|
<entry>date start_date, int day_count=1</entry>
|
|
<entry>Iterate day_count days at a time.</entry>
|
|
</row>
|
|
<row>
|
|
<entry>week_iterator</entry>
|
|
<entry> date start_date, int week_offset=1</entry>
|
|
<entry>Iterate week_offset weeks at a time.</entry>
|
|
</row>
|
|
<row>
|
|
<entry>month_iterator</entry>
|
|
<entry>date start_date, int month_offset=1</entry>
|
|
<entry>
|
|
Iterate month_offset months. There are special rules for handling the end of the month. These are: if start date is last day of the month, always adjust to last day of the month. If date is beyond the end of the month (eg: jan 31 + 1 month) adjust back to end of month.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>year_iterator</entry>
|
|
<entry>date start_date, int year_offset=1</entry>
|
|
<entry>Iterate year_offset years. The year_iterator will always land on the day of the date parameter except when date is Feb 28 in a non-leap year. In this case the iterator will return Feb 29 for leap years (eg: 2003-Feb-28, 2004-Feb-29, 2005-Feb-28).</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
|
|
|
|
<link linkend="top">top</link>
|
|
</section>
|