Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
C++ Boost

gregorian::date iterators


Overall Index -- Gregorian Index -- Posix Time Index

Date Generators / Algorithms

Introduction -- Header -- Class Overview


Date iterators provide a standard mechanism for iteration through dates. Date iterators are are similar to Bidirectional Iterators and can be used to populate collections with dates and other date generation tasks. For example, the print month example iterates through all the days in a month and prints them.

All of the iterators here derive from boost::gregorian::date_iterator and provide a various comparison operations against dates including equal, not equal, less, lees equal, greater, and greater equal.


#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types

Class Overview

Class Construction Parameters Description
date_iterator Common base class for all day level iterators.
day_iterator date start_date, int day_count=1 Iterate day_count days at a time.
week_iterator date start_date, int week_offset=1 Iterate week_offset weeks at a time.
month_iterator date start_date, int month_offset=1 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.
year_iterator date start_date, int year_offset=1 Iterate year_offset years

Last modified: Sun Jan 18 14:32:56 MST 2004 by Jeff Garland © 2000-2002