mirror of
https://github.com/boostorg/date_time.git
synced 2026-02-23 15:42:20 +00:00
79 lines
2.6 KiB
HTML
79 lines
2.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
|
<title>posix_time::time iterators Documentation</title>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
|
</head>
|
|
|
|
<body>
|
|
<a href="../../../index.htm">
|
|
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
|
</a>
|
|
|
|
<h1>posix_time::time iterators</h1>
|
|
<p> <p>
|
|
<hr>
|
|
<a href="index.html">Overall Index</a> --
|
|
<a href="gregorian.html">Gregorian Index</a> --
|
|
<a href="posix_time.html">Posix Time Index</a>
|
|
<p>
|
|
<font class="bold">Time Iterators</font>
|
|
<p>
|
|
<a href="#intro">Introduction</a> --
|
|
<a href="#header">Header</a> --
|
|
<a href="#classoverview">Class Overview</a>
|
|
|
|
<p>
|
|
<h2><a name="intro">Introduction</a></h2>
|
|
|
|
<p>
|
|
Time iterators provide a standard mechanism for iteration through times. Time iterators are a model of
|
|
<a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> and can be used to populate collections with times. The following example
|
|
iterates using a 15 minute iteration interval.
|
|
<p>
|
|
<div class="fragment"><pre>
|
|
|
|
<font class="keyword">using namespace</font> boost::gregorian;
|
|
<font class="keyword">using namespace</font> boost::posix_time;
|
|
date d(2000,Jan,20);
|
|
ptime start(d);<font class="comment">//2000-Jan-20 00:00:00</font>
|
|
time_iterator titr(start,minutes(15)); <font class="comment">//iterate on 15 minute intervals</font>
|
|
<font class="comment">//produces 00:00:00, 00:15:00, 00:30:00, 00:45:00</font>
|
|
<font class="keyword">for</font> (; titr < ptime(d,hour(1)); ++titr) {
|
|
std::cout << to_simple_string(*titr) << std::endl;
|
|
}
|
|
</pre></div>
|
|
<p>
|
|
The <a href="exp-print_hours.html">print hours</a>
|
|
example iterates through the remainder of the day incrementing by an hour.
|
|
|
|
<p>
|
|
<h2><a name="header">Header</a></h2>
|
|
<pre>
|
|
#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
|
|
</pre>
|
|
<p>
|
|
<h2><a name="classoverview">Class Overview</a></h2>
|
|
<p>
|
|
<table border=1 cellspacing=3 cellpadding=3>
|
|
<tr><td><b>Class</b></td>
|
|
<td><b>Construction Parameters</b></td>
|
|
<td><b>Description</b></td></tr>
|
|
<tr><td>time_iterator</td>
|
|
<td>ptime start_time, time_duration increment</td>
|
|
<td>Iterate incrementing by the specified duration.</td></tr>
|
|
</table>
|
|
|
|
|
|
<hr><address><small>
|
|
<!-- hhmts start -->
|
|
Last modified: Thu Sep 5 07:23:04 MST 2002
|
|
<!-- hhmts end -->
|
|
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
|
</small></address>
|
|
|
|
</body>
|
|
</html>
|
|
|