# posix_time::time iterators

Overall Index -- Gregorian Index -- Posix Time Index

Time Iterators

Introduction -- Header -- Class Overview

## Introduction

Time iterators provide a standard mechanism for iteration through times. Time iterators are a model of Input Iterator and can be used to populate collections with times. The following example iterates using a 15 minute interation interval.

      using namespace boost::gregorian;
      using namespace boost::posix_time;
      date d(2000,Jan,20);
      ptime start(d);//2000-Jan-20 00:00:00
      time_iterator titr(start,minutes(15)); //iterate on 15 minute intervals
      //produces 00:00:00, 00:15:00, 00:30:00, 00:45:00
      for (; titr < ptime(d,hour(1)); ++titr) {
        std::cout << to_simple_string(*titr) << std::endl;
      }

The print hours example iterates through the remainder of the day incrementing by an hour.

## Header

    #include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
    or
    #include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types

## Class Overview

Class | Construction Parameters | Description
time_iterator | ptime start_time, time_duration increment | Iterate incrementing by the specified duration.