Imported Upstream version 1.72.0
[platform/upstream/boost.git] / doc / html / date_time / posix_time.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>Posix Time</title>
6 <link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
7 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8 <link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9 <link rel="up" href="../date_time.html" title="Chapter&#160;13.&#160;Boost.Date_Time">
10 <link rel="prev" href="gregorian.html" title="Gregorian">
11 <link rel="next" href="local_time.html" title="Local Time">
12 </head>
13 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14 <table cellpadding="2" width="100%"><tr>
15 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
16 <td align="center"><a href="../../../index.html">Home</a></td>
17 <td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
18 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20 <td align="center"><a href="../../../more/index.htm">More</a></td>
21 </tr></table>
22 <hr>
23 <div class="spirit-nav">
24 <a accesskey="p" href="gregorian.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../date_time.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="local_time.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
25 </div>
26 <div class="section">
27 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
28 <a name="date_time.posix_time"></a>Posix Time</h2></div></div></div>
29 <div class="toc"><dl class="toc">
30 <dt><span class="section"><a href="posix_time.html#date_time.posix_time.ptime_class">Ptime</a></span></dt>
31 <dt><span class="section"><a href="posix_time.html#date_time.posix_time.time_duration">Time Duration</a></span></dt>
32 <dt><span class="section"><a href="posix_time.html#date_time.posix_time.time_period">Time Period</a></span></dt>
33 <dt><span class="section"><a href="posix_time.html#date_time.posix_time.time_iterators">Time Iterators</a></span></dt>
34 </dl></div>
35 <h3>
36 <a name="id-1.3.14.9.2"></a>Posix Time System</h3>
37 <p>
38     <a class="link" href="posix_time.html#posix_intro">Introduction</a> -- 
39     <a class="link" href="posix_time.html#posix_ex">Usage Examples</a>
40   </p>
41 <a name="posix_intro"></a><h4>
42 <a name="id-1.3.14.9.5"></a>Introduction</h4>
43 <p>
44     Defines a non-adjusted time system with nano-second/micro-second resolution and stable calculation properties.  The nano-second resolution option uses 96 bits of underlying storage for each ptime while the micro-second resolution uses 64 bits per ptime (see <a class="link" href="details.html#date_time.buildinfo" title="Build-Compiler Information">Build Options</a> for details). This time system uses the Gregorian calendar to implement the date portion of the time representation. 
45   </p>
46 <a name="posix_ex"></a><h4>
47 <a name="id-1.3.14.9.8"></a>Usage Examples</h4>
48 <p>
49     </p>
50 <div class="informaltable"><table class="table">
51 <colgroup>
52 <col>
53 <col>
54 </colgroup>
55 <thead><tr>
56 <th>Example</th>
57 <th>Description</th>
58 </tr></thead>
59 <tbody>
60 <tr>
61 <td><a class="link" href="examples.html#date_time.examples.time_math" title="Time Math">Time Math</a></td>
62 <td>A few simple calculations using ptime and time_durations.</td>
63 </tr>
64 <tr>
65 <td><a class="link" href="examples.html#date_time.examples.print_hours" title="Print Hours">Print Hours</a></td>
66 <td>Retrieve time from clock, use a time_iterator.</td>
67 </tr>
68 <tr>
69 <td><a class="link" href="examples.html#date_time.examples.local_utc_conversion" title="Local to UTC Conversion">Local to UTC Conversion</a></td>
70 <td>Demonstrates a couple different ways to convert a local to UTC time including daylight savings rules.</td>
71 </tr>
72 <tr>
73 <td><a class="link" href="examples.html#date_time.examples.time_periods" title="Time Periods">Time Periods</a></td>
74 <td>Some simple examples of intersection and display of time periods.</td>
75 </tr>
76 </tbody>
77 </table></div>
78 <p>
79   </p>
80 <div class="section">
81 <div class="titlepage"><div><div><h3 class="title">
82 <a name="date_time.posix_time.ptime_class"></a>Ptime</h3></div></div></div>
83 <a class="link" href="posix_time.html#ptime_intro">Introduction</a> --
84   <a class="link" href="posix_time.html#ptime_header">Header</a> --
85   <a class="link" href="posix_time.html#ptime_constr">Construction</a> --
86   <a class="link" href="posix_time.html#ptime_from_string">Construct from String</a> --
87   <a class="link" href="posix_time.html#ptime_from_clock">Construct from Clock</a> --
88   <a class="link" href="posix_time.html#ptime_from_funcs">Construct using Conversion functions</a> --
89   <a class="link" href="posix_time.html#ptime_accessors">Accessors</a> --
90   <a class="link" href="posix_time.html#ptime_to_string">Conversion To String</a> --
91   <a class="link" href="posix_time.html#ptime_operators">Operators</a> --
92   <a class="link" href="posix_time.html#ptime_struct_tm">Struct tm, time_t, and FILETIME Functions</a><a name="ptime_intro"></a><h4>
93 <a name="id-1.3.14.9.10.13"></a>Introduction</h4>
94 <p>
95     The class boost::posix_time::ptime is the primary interface for time point manipulation. In general, the ptime class is immutable once constructed although it does allow assignment. 
96   </p>
97 <p>
98     Class ptime is dependent on <a class="link" href="gregorian.html#date_time.gregorian.date_class" title="Date">gregorian::date</a> for the interface to the date portion of a time point. 
99   </p>
100 <p>
101     Other techniques for creating times include <a class="link" href="posix_time.html#date_time.posix_time.time_iterators" title="Time Iterators">time iterators</a>. 
102   </p>
103 <a name="ptime_header"></a><h4>
104 <a name="id-1.3.14.9.10.18"></a>Header</h4>
105 <p>
106     </p>
107 <pre class="programlisting">#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
108 or
109 #include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types</pre>
110 <p>
111   </p>
112 <a name="ptime_constr"></a><h4>
113 <a name="id-1.3.14.9.10.21"></a>Construction</h4>
114 <p>
115     </p>
116 <div class="informaltable"><table class="table">
117 <colgroup>
118 <col>
119 <col>
120 </colgroup>
121 <thead>
122 <tr>
123 <th rowspan="2" valign="top">Syntax</th>
124 <th>Description</th>
125 </tr>
126 <tr><th>Example</th></tr>
127 </thead>
128 <tbody>
129 <tr>
130 <td rowspan="2" valign="top"><pre class="screen">ptime(date,time_duration)</pre></td>
131 <td>Construct from a date and offset</td>
132 </tr>
133 <tr><td>
134 <pre class="screen">ptime t1(date(2002,Jan,10), 
135          time_duration(1,2,3));
136 ptime t2(date(2002,Jan,10), 
137          hours(1)+nanosec(5));</pre>
138             </td></tr>
139 <tr>
140 <td rowspan="2" valign="top"><pre class="screen">ptime(ptime)</pre></td>
141 <td>Copy constructor</td>
142 </tr>
143 <tr><td><pre class="screen">ptime t3(t1)</pre></td></tr>
144 <tr>
145 <td rowspan="2" valign="top"><pre class="screen">ptime(special_values sv)</pre></td>
146 <td>Constructor for infinities, not-a-date-time, max_date_time, and min_date_time</td>
147 </tr>
148 <tr><td><pre class="screen">ptime d1(neg_infin);
149 ptime d2(pos_infin);
150 ptime d3(not_a_date_time);
151 ptime d4(max_date_time);
152 ptime d5(min_date_time);</pre></td></tr>
153 <tr>
154 <td rowspan="2" valign="top"><pre class="screen">ptime;</pre></td>
155 <td>Default constructor. Creates a ptime object initialized to not_a_date_time. NOTE: this constructor can be disabled by defining DATE_TIME_NO_DEFAULT_CONSTRUCTOR (see compiler_config.hpp)</td>
156 </tr>
157 <tr><td><pre class="screen">ptime p; // p =&gt; not_a_date_time</pre></td></tr>
158 </tbody>
159 </table></div>
160 <p>
161   </p>
162 <a name="ptime_from_string"></a><h4>
163 <a name="id-1.3.14.9.10.24"></a>Construct from String</h4>
164 <p>
165     </p>
166 <div class="informaltable"><table class="table">
167 <colgroup>
168 <col>
169 <col>
170 </colgroup>
171 <thead>
172 <tr>
173 <th rowspan="2" valign="top">Syntax</th>
174 <th>Description</th>
175 </tr>
176 <tr><th>Example</th></tr>
177 </thead>
178 <tbody>
179 <tr>
180 <td rowspan="2" valign="top"><pre class="screen">ptime time_from_string(std::string)</pre></td>
181 <td>From delimited string. NOTE: Excess digits in fractional seconds will be dropped. Ex: "1:02:03.123456999" =&gt; 1:02:03.123456. This behavior is affected by the precision the library is compiled with (see <a class="link" href="details.html#date_time.buildinfo" title="Build-Compiler Information">Build-Compiler Information</a>.</td>
182 </tr>
183 <tr><td><pre class="screen">std::string ts("2002-01-20 23:59:59.000");
184 ptime t(time_from_string(ts))</pre></td></tr>
185 <tr>
186 <td rowspan="2" valign="top"><pre class="screen">ptime from_iso_string(std::string)</pre></td>
187 <td>From non delimited iso form string.</td>
188 </tr>
189 <tr><td><pre class="screen">std::string ts("20020131T235959");
190 ptime t(from_iso_string(ts))</pre></td></tr>
191 </tbody>
192 </table></div>
193 <p>
194   </p>
195 <a name="ptime_from_clock"></a><h4>
196 <a name="id-1.3.14.9.10.27"></a>Construct from Clock</h4>
197 <p>
198     </p>
199 <div class="informaltable"><table class="table">
200 <colgroup>
201 <col>
202 <col>
203 </colgroup>
204 <thead>
205 <tr>
206 <th rowspan="2" valign="top">Syntax</th>
207 <th>Description</th>
208 </tr>
209 <tr><th>Example</th></tr>
210 </thead>
211 <tbody>
212 <tr>
213 <td rowspan="2" valign="top"><pre class="screen">ptime second_clock::local_time()</pre></td>
214 <td>Get the local time, second level resolution, based on the time zone settings of the computer.</td>
215 </tr>
216 <tr><td><pre class="screen">ptime t(second_clock::local_time());</pre></td></tr>
217 <tr>
218 <td rowspan="2" valign="top"><pre class="screen">ptime second_clock::universal_time()</pre></td>
219 <td>Get the UTC time.</td>
220 </tr>
221 <tr><td><pre class="screen">ptime t(second_clock::universal_time())</pre></td></tr>
222 <tr>
223 <td rowspan="2" valign="top"><pre class="screen">ptime microsec_clock::local_time()</pre></td>
224 <td>Get the local time using a sub second resolution clock.  On Unix systems this is implemented using GetTimeOfDay.  On most Win32 platforms it is implemented using ftime.  Win32 systems often do not achieve microsecond resolution via this API.  If higher resolution is critical to your application test your platform to see the achieved resolution.</td>
225 </tr>
226 <tr><td><pre class="screen">ptime t(microsec_clock::local_time());</pre></td></tr>
227 <tr>
228 <td rowspan="2" valign="top"><pre class="screen">ptime microsec_clock::universal_time()</pre></td>
229 <td>Get the UTC time using a sub second resolution clock.  On Unix systems this is implemented using GetTimeOfDay.  On most Win32 platforms it is implemented using ftime.  Win32 systems often do not achieve microsecond resolution via this API.  If higher resolution is critical to your application test your platform to see the achieved resolution.</td>
230 </tr>
231 <tr><td><pre class="screen">ptime t(microsec_clock::universal_time());</pre></td></tr>
232 </tbody>
233 </table></div>
234 <p>
235   </p>
236 <a name="ptime_from_funcs"></a><h4>
237 <a name="id-1.3.14.9.10.30"></a>Construct using Conversion Functions</h4>
238 <p>
239     </p>
240 <div class="informaltable"><table class="table">
241 <colgroup>
242 <col>
243 <col>
244 </colgroup>
245 <thead>
246 <tr>
247 <th rowspan="2" valign="top">Syntax</th>
248 <th>Description</th>
249 </tr>
250 <tr><th>Example</th></tr>
251 </thead>
252 <tbody>
253 <tr>
254 <td rowspan="2" valign="top"><pre class="screen">ptime from_time_t(time_t t);</pre></td>
255 <td>Converts a time_t into a ptime.</td>
256 </tr>
257 <tr><td><pre class="screen">ptime t = from_time_t(tt);</pre></td></tr>
258 <tr>
259 <td rowspan="2" valign="top"><pre class="screen">ptime from_ftime&lt;ptime&gt;(FILETIME ft);</pre></td>
260 <td>Creates a ptime object from a FILETIME structure.</td>
261 </tr>
262 <tr><td><pre class="screen">ptime t = from_ftime&lt;ptime&gt;(ft);</pre></td></tr>
263 </tbody>
264 </table></div>
265 <p>
266   </p>
267 <a name="ptime_accessors"></a><h4>
268 <a name="id-1.3.14.9.10.33"></a>Accessors</h4>
269 <p>
270     </p>
271 <div class="informaltable"><table class="table">
272 <colgroup>
273 <col>
274 <col>
275 </colgroup>
276 <thead>
277 <tr>
278 <th rowspan="2" valign="top">Syntax</th>
279 <th>Description</th>
280 </tr>
281 <tr><th>Example</th></tr>
282 </thead>
283 <tbody>
284 <tr>
285 <td rowspan="2" valign="top"><pre class="screen">date date()</pre></td>
286 <td>Get the date part of a time.</td>
287 </tr>
288 <tr><td>
289 <pre class="screen">date d(2002,Jan,10);
290 ptime t(d, hour(1));
291 t.date() --&gt; 2002-Jan-10;</pre>
292             </td></tr>
293 <tr>
294 <td rowspan="2" valign="top"><pre class="screen">time_duration time_of_day()</pre></td>
295 <td>Get the time offset in the day.</td>
296 </tr>
297 <tr><td>
298 <pre class="screen">date d(2002,Jan,10);
299 ptime t(d, hour(1));
300 t.time_of_day() --&gt; 01:00:00;</pre>
301             </td></tr>
302 <tr>
303 <td rowspan="2" valign="top"><pre class="screen">bool is_infinity() const</pre></td>
304 <td>Returns true if ptime is either positive or negative infinity</td>
305 </tr>
306 <tr><td><pre class="screen">ptime pt(pos_infin); 
307 pt.is_infinity(); // --&gt; true</pre></td></tr>
308 <tr>
309 <td rowspan="2" valign="top"><pre class="screen">bool is_neg_infinity() const</pre></td>
310 <td>Returns true if ptime is negative infinity</td>
311 </tr>
312 <tr><td><pre class="screen">ptime pt(neg_infin);
313 pt.is_neg_infinity(); // --&gt; true</pre></td></tr>
314 <tr>
315 <td rowspan="2" valign="top"><pre class="screen">bool is_pos_infinity() const</pre></td>
316 <td>Returns true if ptime is positive infinity</td>
317 </tr>
318 <tr><td><pre class="screen">ptime pt(neg_infin); 
319 pt.is_pos_infinity(); // --&gt; true</pre></td></tr>
320 <tr>
321 <td rowspan="2" valign="top"><pre class="screen">bool is_not_a_date_time() const</pre></td>
322 <td>Returns true if value is not a ptime</td>
323 </tr>
324 <tr><td><pre class="screen">ptime pt(not_a_date_time);
325 pt.is_not_a_date_time(); // --&gt; true</pre></td></tr>
326 <tr>
327 <td rowspan="2" valign="top"><pre class="screen">bool is_special() const</pre></td>
328 <td>Returns true if ptime is any <code class="computeroutput">special_value</code>
329 </td>
330 </tr>
331 <tr><td><pre class="screen">ptime pt(pos_infin); 
332 ptime pt2(not_a_date_time); 
333 ptime pt3(date(2005,Mar,1), hours(10));
334 pt.is_special(); // --&gt; true
335 pt2.is_special(); // --&gt; true
336 pt3.is_special(); // --&gt; false</pre></td></tr>
337 </tbody>
338 </table></div>
339 <p>
340   </p>
341 <a name="ptime_to_string"></a><h4>
342 <a name="id-1.3.14.9.10.36"></a>Conversion to String</h4>
343 <p>
344     </p>
345 <div class="informaltable"><table class="table">
346 <colgroup>
347 <col>
348 <col>
349 </colgroup>
350 <thead>
351 <tr>
352 <th rowspan="2" valign="top">Syntax</th>
353 <th>Description</th>
354 </tr>
355 <tr><th>Example</th></tr>
356 </thead>
357 <tbody>
358 <tr>
359 <td rowspan="2" valign="top"><pre class="screen">std::string to_simple_string(ptime)</pre></td>
360 <td>To <code class="computeroutput">YYYY-mmm-DD HH:MM:SS.fffffffff</code> string where <code class="computeroutput">mmm</code> 3 char month name. Fractional seconds only included if non-zero.</td>
361 </tr>
362 <tr><td><pre class="screen">2002-Jan-01 10:00:01.123456789</pre></td></tr>
363 <tr>
364 <td rowspan="2" valign="top"><pre class="screen">std::string to_iso_string(ptime)</pre></td>
365 <td>Convert to form <code class="computeroutput">YYYYMMDDTHHMMSS,fffffffff</code> where <code class="computeroutput">T</code> is the date-time separator</td>
366 </tr>
367 <tr><td><pre class="screen">20020131T100001,123456789</pre></td></tr>
368 <tr>
369 <td rowspan="2" valign="top"><pre class="screen">std::string to_iso_extended_string(ptime)</pre></td>
370 <td>Convert to form <code class="computeroutput">YYYY-MM-DDTHH:MM:SS,fffffffff</code> where <code class="computeroutput">T</code> is the date-time separator</td>
371 </tr>
372 <tr><td><pre class="screen">2002-01-31T10:00:01,123456789</pre></td></tr>
373 </tbody>
374 </table></div>
375 <p>
376   </p>
377 <a name="ptime_operators"></a><h4>
378 <a name="id-1.3.14.9.10.39"></a>Operators</h4>
379 <p>
380     </p>
381 <div class="informaltable"><table class="table">
382 <colgroup>
383 <col>
384 <col>
385 </colgroup>
386 <thead>
387 <tr>
388 <th rowspan="2" valign="top">Syntax</th>
389 <th>Description</th>
390 </tr>
391 <tr><th>Example</th></tr>
392 </thead>
393 <tbody>
394 <tr>
395 <td rowspan="2" valign="top"><pre class="screen">operator&lt;&lt;, operator&gt;&gt;</pre></td>
396 <td>Streaming operators. <span class="strong"><strong>Note:</strong></span> As of version 1.33, streaming operations have been greatly improved. See <a class="link" href="date_time_io.html" title="Date Time Input/Output">Date Time IO System</a> for more details (including exceptions and error conditions).</td>
397 </tr>
398 <tr><td>
399 <pre class="screen">ptime pt(not_a_date_time);
400 stringstream ss("2002-Jan-01 14:23:11");
401 ss &gt;&gt; pt; 
402 std::cout &lt;&lt; pt; // "2002-Jan-01 14:23:11"
403   </pre>
404             </td></tr>
405 <tr>
406 <td rowspan="2" valign="top">
407 <pre class="screen">operator==, operator!=,
408 operator&gt;, operator&lt;,
409 operator&gt;=, operator&lt;=</pre>
410             </td>
411 <td>A full complement of comparison operators</td>
412 </tr>
413 <tr><td><pre class="screen">t1 == t2, etc</pre></td></tr>
414 <tr>
415 <td rowspan="2" valign="top"><pre class="screen">ptime operator+(days)</pre></td>
416 <td>Return a ptime adding a day offset</td>
417 </tr>
418 <tr><td>
419 <pre class="screen">date d(2002,Jan,1);
420 ptime t(d,minutes(5));
421 days dd(1);
422 ptime t2 = t + dd;</pre>
423             </td></tr>
424 <tr>
425 <td rowspan="2" valign="top"><pre class="screen">ptime operator-(days)</pre></td>
426 <td>Return a ptime subtracting a day offset</td>
427 </tr>
428 <tr><td>
429 <pre class="screen">date d(2002,Jan,1);
430 ptime t(d,minutes(5));
431 days dd(1);
432 ptime t2 = t - dd;</pre>
433             </td></tr>
434 <tr>
435 <td rowspan="2" valign="top"><pre class="screen">ptime operator+(time_duration)</pre></td>
436 <td>Return a ptime adding a time duration</td>
437 </tr>
438 <tr><td>
439 <pre class="screen">date d(2002,Jan,1);
440 ptime t(d,minutes(5));
441 ptime t2 = t + hours(1) + minutes(2);</pre>
442             </td></tr>
443 <tr>
444 <td rowspan="2" valign="top"><pre class="screen">ptime operator-(time_duration)</pre></td>
445 <td>Return a ptime subtracting a time duration</td>
446 </tr>
447 <tr><td>
448 <pre class="screen">date d(2002,Jan,1);
449 ptime t(d,minutes(5));
450 ptime t2 = t - minutes(2);</pre>
451             </td></tr>
452 <tr>
453 <td rowspan="2" valign="top"><pre class="screen">time_duration operator-(ptime)</pre></td>
454 <td>Take the difference between two times.</td>
455 </tr>
456 <tr><td>
457 <pre class="screen">date d(2002,Jan,1);
458 ptime t1(d,minutes(5));
459 ptime t2(d,seconds(5));
460 time_duration t3 = t2 - t1;//negative result</pre>
461             </td></tr>
462 </tbody>
463 </table></div>
464 <p>
465   </p>
466 <a name="ptime_struct_tm"></a><h4>
467 <a name="id-1.3.14.9.10.42"></a>Struct tm, time_t, and FILETIME Functions</h4>
468 <p>Functions for converting posix_time objects to, and from, <code class="computeroutput">tm</code> structs are provided as well as conversion from <code class="computeroutput">time_t</code> and <code class="computeroutput">FILETIME</code>.</p>
469 <div class="informaltable"><table class="table">
470 <colgroup>
471 <col>
472 <col>
473 </colgroup>
474 <thead>
475 <tr>
476 <th rowspan="2" valign="top">Syntax</th>
477 <th>Description</th>
478 </tr>
479 <tr><th>Example</th></tr>
480 </thead>
481 <tbody>
482 <tr>
483 <td rowspan="2" valign="top"><pre class="screen">tm to_tm(ptime)</pre></td>
484 <td>A function for converting a <code class="computeroutput">ptime</code> object to a <code class="computeroutput">tm</code> struct. The <code class="computeroutput">tm_isdst</code> field is set to -1.</td>
485 </tr>
486 <tr><td>
487 <pre class="screen">ptime pt(date(2005,Jan,1), time_duration(1,2,3));
488 tm pt_tm = to_tm(pt);
489 /* tm_year =&gt; 105
490    tm_mon  =&gt; 0
491    tm_mday =&gt; 1
492    tm_wday =&gt; 6 (Saturday)
493    tm_yday =&gt; 0
494    tm_hour =&gt; 1
495    tm_min  =&gt; 2
496    tm_sec  =&gt; 3
497    tm_isddst =&gt; -1 */</pre>
498           </td></tr>
499 <tr>
500 <td rowspan="2" valign="top"><pre class="screen">ptime ptime_from_tm(tm timetm)</pre></td>
501 <td>A function for converting a <code class="computeroutput">tm</code> struct to a <code class="computeroutput">ptime</code> object. The fields: <code class="computeroutput">tm_wday </code>, <code class="computeroutput">tm_yday </code>, and <code class="computeroutput">tm_isdst</code> are ignored.</td>
502 </tr>
503 <tr><td>
504 <pre class="screen">tm pt_tm;
505 pt_tm.tm_year = 105;
506 pt_tm.tm_mon  = 0;
507 pt_tm.tm_mday = 1;
508 pt_tm.tm_hour = 1;
509 pt_tm.tm_min  = 2;
510 pt_tm.tm_sec  = 3;
511 ptime pt = ptime_from_tm(pt_tm);
512 // pt =&gt; 2005-Jan-01 01:02:03</pre>
513           </td></tr>
514 <tr>
515 <td rowspan="2" valign="top"><pre class="screen">tm to_tm(time_duration)</pre></td>
516 <td>A function for converting a <code class="computeroutput">time_duration</code> object to a <code class="computeroutput">tm</code> struct. The fields: <code class="computeroutput">tm_year</code>, <code class="computeroutput">tm_mon</code>, <code class="computeroutput">tm_mday</code>, <code class="computeroutput">tm_wday</code>, <code class="computeroutput">tm_yday</code> are set to zero. The <code class="computeroutput">tm_isdst</code> field is set to -1.</td>
517 </tr>
518 <tr><td>
519 <pre class="screen">time_duration td(1,2,3);
520 tm td_tm = to_tm(td);
521 /* tm_year =&gt; 0
522    tm_mon  =&gt; 0
523    tm_mday =&gt; 0
524    tm_wday =&gt; 0
525    tm_yday =&gt; 0
526    tm_hour =&gt; 1
527    tm_min  =&gt; 2
528    tm_sec  =&gt; 3
529    tm_isddst =&gt; -1 */</pre>
530           </td></tr>
531 <tr>
532 <td rowspan="2" valign="top"><pre class="screen">ptime from_time_t(std::time_t)</pre></td>
533 <td>Creates a <code class="computeroutput">ptime</code> from the time_t parameter. The seconds held in the time_t are added to a time point of 1970-Jan-01.</td>
534 </tr>
535 <tr><td><pre class="screen">ptime pt(not_a_date_time);
536 std::time_t t;
537 t = 1118158776;
538 pt = from_time_t(t);
539 // pt =&gt; 2005-Jun-07 15:39:36</pre></td></tr>
540 <tr>
541 <td rowspan="2" valign="top"><pre class="screen">ptime from_ftime&lt;ptime&gt;(FILETIME)</pre></td>
542 <td>A template function that constructs a <code class="computeroutput">ptime</code> from a FILETIME struct.</td>
543 </tr>
544 <tr><td><pre class="screen">FILETIME ft;
545 ft.dwHighDateTime = 29715317;
546 ft.dwLowDateTime = 3865122988UL;
547 ptime pt = from_ftime&lt;ptime&gt;(ft);
548 // pt =&gt; 2005-Jun-07 15:30:57.039582000</pre></td></tr>
549 </tbody>
550 </table></div>
551 </div>
552 <div class="section">
553 <div class="titlepage"><div><div><h3 class="title">
554 <a name="date_time.posix_time.time_duration"></a>Time Duration</h3></div></div></div>
555 <a class="link" href="posix_time.html#time_duration_intro">Introduction</a> --
556   <a class="link" href="posix_time.html#time_duration_header">Header</a> --
557   <a class="link" href="posix_time.html#time_duration_constr">Construction</a> --
558   <a class="link" href="posix_time.html#time_duration_count_constr">Count Based Construction</a> --
559   <a class="link" href="posix_time.html#time_duration_from_string">Construct from String</a> --
560   <a class="link" href="posix_time.html#time_duration_accessors">Accessors</a> --
561   <a class="link" href="posix_time.html#time_duration_to_string">Conversion To String</a> --
562   <a class="link" href="posix_time.html#time_duration_operators">Operators</a> --
563   <a class="link" href="posix_time.html#time_duration_struct_tm">Struct tm Functions</a><a name="time_duration_intro"></a><h4>
564 <a name="id-1.3.14.9.11.12"></a>Introduction</h4>
565 <p>
566     The class boost::posix_time::time_duration the base type responsible for representing a length of time. A duration can be either positive or negative. The general time_duration class provides a constructor that takes a count of the number of hours, minutes, seconds, and fractional seconds count as shown in the code fragment below. The resolution of the time_duration is configure able at compile time. See <a class="link" href="details.html#date_time.buildinfo" title="Build-Compiler Information">Build-Compiler Information</a> for more information. 
567   </p>
568 <p>
569     </p>
570 <pre class="programlisting">using namespace boost::posix_time;
571 time_duration td(1,2,3,4); //01:02:03.000000004 when resolution is nano seconds
572 time_duration td(1,2,3,4); //01:02:03.000004 when resolution is micro seconds</pre>
573 <p>
574   </p>
575 <p>
576     Several small helper classes that derive from a base time_duration, as shown below, to adjust for different resolutions. These classes can shorten code and make the intent clearer.
577   </p>
578 <img src="../../../libs/date_time/doc/time_duration_inherit.png"><p>
579     As an example: 
580     </p>
581 <pre class="programlisting">using namespace boost::posix_time;
582       
583 time_duration td = hours(1) + seconds(10); //01:00:10
584 td = hours(1) + nanoseconds(5); //01:00:00.000000005</pre>
585 <p>
586     Note that the existence of the higher resolution classes (eg: nanoseconds) depends on the installation of the library. See <a class="link" href="details.html#date_time.buildinfo" title="Build-Compiler Information">Build-Compiler Information</a> for more information. 
587   </p>
588 <p>
589      Another way to handle this is to utilize the ticks_per_second() method of time_duration to
590      write code that is portable no matter how the library is compiled.   The general equation
591      for calculating a resolution independent count is as follows:
592
593     </p>
594 <pre class="programlisting">
595 count*(time_duration_ticks_per_second / count_ticks_per_second)
596     </pre>
597 <p>
598
599      For example, let's suppose we want to construct using a count that represents tenths 
600      of a second.  That is, each tick is 0.1 second. 
601     </p>
602 <pre class="programlisting">
603 int number_of_tenths = 5;
604 //create a resolution independent count -- divide by 10 since there are 
605 //10 tenths in a second.  
606 int count = number_of_tenths*(time_duration::ticks_per_second()/10);
607 time_duration td(1,2,3,count); //01:02:03.5 //no matter the resolution settings
608     </pre>
609 <p>
610   </p>
611 <a name="time_duration_header"></a><h4>
612 <a name="id-1.3.14.9.11.20"></a>Header</h4>
613 <p>
614     </p>
615 <pre class="programlisting">#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
616 or
617 #include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types</pre>
618 <p>
619   </p>
620 <a name="time_duration_constr"></a><h4>
621 <a name="id-1.3.14.9.11.23"></a>Construction</h4>
622 <p>
623     </p>
624 <div class="informaltable"><table class="table">
625 <colgroup>
626 <col>
627 <col>
628 </colgroup>
629 <thead>
630 <tr>
631 <th rowspan="2" valign="top">Syntax</th>
632 <th>Description</th>
633 </tr>
634 <tr><th>Example</th></tr>
635 </thead>
636 <tbody>
637 <tr>
638 <td rowspan="2" valign="top"><pre class="screen">time_duration(hours,
639               minutes,
640               seconds,
641               fractional_seconds)</pre></td>
642 <td>Construct a duration from the counts. The fractional_second parameter is a number of units and is therefore affected by the resolution the application is compiled with (see <a class="link" href="details.html#compile_options">Build-Compiler Information</a>). If the fractional_seconds argument exceeds the limit of the compiled precision, the excess value will be "carried over" into the seconds field.  See above for techniques to creating a resolution independent count.</td>
643 </tr>
644 <tr><td><pre class="screen">time_duration td(1,2,3,9);
645 //1 hr 2 min 3 sec 9 nanoseconds
646 time_duration td2(1,2,3,123456789);
647 time_duration td3(1,2,3,1000);
648 // with microsecond resolution (6 digits)
649 // td2 =&gt; "01:04:06.456789"
650 // td3 =&gt; "01:02:03.001000"
651 // with nanosecond resolution (9 digits)
652 // td2 =&gt; "01:02:03.123456789"
653 // td3 =&gt; "01:02:03.000001000"</pre></td></tr>
654 <tr>
655 <td valign="top"><pre class="screen">time_duration(special_value sv)</pre></td>
656 <td>Special values constructor. <span class="strong"><strong>Important note</strong></span>: When a time_duration is a special value, either by construction or other means, the following accessor functions will give unpredictable results: <pre class="screen">hours(), minutes(), seconds(), ticks(), 
657 fractional_seconds(), total_nanoseconds(),
658 total_microseconds(), total_milliseconds(),
659 total_seconds()</pre>The remaining accessor functions will work as expected.</td>
660 </tr>
661 </tbody>
662 </table></div>
663 <p>
664   </p>
665 <a name="time_duration_count_constr"></a><h4>
666 <a name="id-1.3.14.9.11.26"></a>Count Based Construction</h4>
667 <p>
668     </p>
669 <div class="informaltable"><table class="table">
670 <colgroup>
671 <col>
672 <col>
673 </colgroup>
674 <thead>
675 <tr>
676 <th rowspan="2" valign="top">Syntax</th>
677 <th>Description</th>
678 </tr>
679 <tr><th>Example</th></tr>
680 </thead>
681 <tbody>
682 <tr>
683 <td rowspan="2" valign="top"><pre class="screen">hours(long)</pre></td>
684 <td>Number of hours</td>
685 </tr>
686 <tr><td><pre class="screen">time_duration td = hours(3);</pre></td></tr>
687 <tr>
688 <td rowspan="2" valign="top"><pre class="screen">minutes(long)</pre></td>
689 <td>Number of minutes</td>
690 </tr>
691 <tr><td><pre class="screen">time_duration td = minutes(3);</pre></td></tr>
692 <tr>
693 <td rowspan="2" valign="top"><pre class="screen">seconds(long)</pre></td>
694 <td> Number of seconds</td>
695 </tr>
696 <tr><td><pre class="screen">time_duration td = seconds(3);</pre></td></tr>
697 <tr>
698 <td rowspan="2" valign="top"><pre class="screen">milliseconds(long)</pre></td>
699 <td>Number of milliseconds.</td>
700 </tr>
701 <tr><td><pre class="screen">time_duration td = milliseconds(3);</pre></td></tr>
702 <tr>
703 <td rowspan="2" valign="top"><pre class="screen">microseconds(long)</pre></td>
704 <td>Number of microseconds.</td>
705 </tr>
706 <tr><td><pre class="screen">time_duration td = microseconds(3);</pre></td></tr>
707 <tr>
708 <td rowspan="2" valign="top"><pre class="screen">nanoseconds(long)</pre></td>
709 <td>Number of nanoseconds.</td>
710 </tr>
711 <tr><td><pre class="screen">time_duration td = nanoseconds(3);</pre></td></tr>
712 </tbody>
713 </table></div>
714 <p>
715   </p>
716 <a name="time_duration_from_string"></a><h4>
717 <a name="id-1.3.14.9.11.29"></a>Construct from String</h4>
718 <p>
719     </p>
720 <div class="informaltable"><table class="table">
721 <colgroup>
722 <col>
723 <col>
724 </colgroup>
725 <thead>
726 <tr>
727 <th rowspan="2" valign="top">Syntax</th>
728 <th>Description</th>
729 </tr>
730 <tr><th>Example</th></tr>
731 </thead>
732 <tbody>
733 <tr>
734 <td rowspan="2" valign="top"><pre class="screen">time_duration duration_from_string(std::string)</pre></td>
735 <td>From delimited string. NOTE: Excess digits in fractional seconds will be dropped. Ex: "1:02:03.123456999" =&gt; 1:02:03.123456. This behavior is affected by the precision the library is compiled with (see <a class="link" href="details.html#date_time.buildinfo" title="Build-Compiler Information">Build-Compiler Information</a>.</td>
736 </tr>
737 <tr><td>
738 <pre class="screen">std::string ts("23:59:59.000");
739 time_duration td(duration_from_string(ts));</pre>
740             </td></tr>
741 </tbody>
742 </table></div>
743 <p>
744   </p>
745 <a name="time_duration_accessors"></a><h4>
746 <a name="id-1.3.14.9.11.32"></a>Accessors</h4>
747 <p>
748     </p>
749 <div class="informaltable"><table class="table">
750 <colgroup>
751 <col>
752 <col>
753 </colgroup>
754 <thead>
755 <tr>
756 <th rowspan="2" valign="top">Syntax</th>
757 <th>Description</th>
758 </tr>
759 <tr><th>Example</th></tr>
760 </thead>
761 <tbody>
762 <tr>
763 <td rowspan="2" valign="top"><pre class="screen">boost::int64_t hours()</pre></td>
764 <td>Get the number of normalized hours (will give unpredictable results if calling <code class="computeroutput">time_duration</code> is a <code class="computeroutput">special_value</code>).</td>
765 </tr>
766 <tr><td><pre class="screen">time_duration td(1,2,3); 
767 time_duration neg_td(-1,2,3);
768 td.hours(); // --&gt; 1
769 neg_td.hours(); // --&gt; -1</pre></td></tr>
770 <tr>
771 <td rowspan="2" valign="top"><pre class="screen">boost::int64_t minutes()</pre></td>
772 <td>Get the number of minutes normalized +/-(0..59) (will give unpredictable results if calling <code class="computeroutput">time_duration</code> is a <code class="computeroutput">special_value</code>).</td>
773 </tr>
774 <tr><td><pre class="screen">time_duration td(1,2,3);
775 time_duration neg_td(-1,2,3);
776 td.minutes(); // --&gt; 2
777 neg_td.minutes(); // --&gt; -2</pre></td></tr>
778 <tr>
779 <td rowspan="2" valign="top"><pre class="screen">boost::int64_t seconds() const</pre></td>
780 <td>Get the normalized number of second +/-(0..59) (will give unpredictable results if calling <code class="computeroutput">time_duration</code> is a <code class="computeroutput">special_value</code>).</td>
781 </tr>
782 <tr><td><pre class="screen">time_duration td(1,2,3); 
783 time_duration neg_td(-1,2,3);
784 td.seconds(); // --&gt; 3
785 neg_td.seconds(); // --&gt; -3</pre></td></tr>
786 <tr>
787 <td rowspan="2" valign="top"><pre class="screen">boost::int64_t total_seconds() const</pre></td>
788 <td>Get the total number of seconds truncating any fractional seconds (will give unpredictable results if calling <code class="computeroutput">time_duration</code> is a <code class="computeroutput">special_value</code>).</td>
789 </tr>
790 <tr><td>
791 <pre class="screen">time_duration td(1,2,3,10);
792 td.total_seconds(); 
793 // --&gt; (1*3600) + (2*60) + 3 == 3723</pre>
794             </td></tr>
795 <tr>
796 <td rowspan="2" valign="top"><pre class="screen">boost::int64_t total_milliseconds() const</pre></td>
797 <td>Get the total number of milliseconds truncating any remaining digits (will give unpredictable results if calling <code class="computeroutput">time_duration</code> is a <code class="computeroutput">special_value</code>).</td>
798 </tr>
799 <tr><td>
800 <pre class="screen">time_duration td(1,2,3,123456789);
801 td.total_milliseconds(); 
802 // HMS --&gt; (1*3600) + (2*60) + 3 == 3723 seconds
803 // milliseconds is 3 decimal places
804 // (3723 * 1000) + 123 == 3723123</pre>
805             </td></tr>
806 <tr>
807 <td rowspan="2" valign="top"><pre class="screen">boost::int64_t total_microseconds() const</pre></td>
808 <td>Get the total number of microseconds truncating any remaining digits (will give unpredictable results if calling <code class="computeroutput">time_duration</code> is a <code class="computeroutput">special_value</code>).</td>
809 </tr>
810 <tr><td>
811 <pre class="screen">time_duration td(1,2,3,123456789);
812 td.total_microseconds(); 
813 // HMS --&gt; (1*3600) + (2*60) + 3 == 3723 seconds
814 // microseconds is 6 decimal places
815 // (3723 * 1000000) + 123456 == 3723123456</pre>
816             </td></tr>
817 <tr>
818 <td rowspan="2" valign="top"><pre class="screen">boost::int64_t total_nanoseconds() const</pre></td>
819 <td>Get the total number of nanoseconds truncating any remaining digits (will give unpredictable results if calling <code class="computeroutput">time_duration</code> is a <code class="computeroutput">special_value</code>).</td>
820 </tr>
821 <tr><td>
822 <pre class="screen">time_duration td(1,2,3,123456789);
823 td.total_nanoseconds(); 
824 // HMS --&gt; (1*3600) + (2*60) + 3 == 3723 seconds
825 // nanoseconds is 9 decimal places
826 // (3723 * 1000000000) + 123456789
827 //                              == 3723123456789</pre>
828             </td></tr>
829 <tr>
830 <td rowspan="2" valign="top"><pre class="screen">boost::int64_t fractional_seconds() const</pre></td>
831 <td>Get the number of fractional seconds (will give unpredictable results if calling <code class="computeroutput">time_duration</code> is a <code class="computeroutput">special_value</code>).</td>
832 </tr>
833 <tr><td><pre class="screen">time_duration td(1,2,3, 1000);
834 td.fractional_seconds(); // --&gt; 1000</pre></td></tr>
835 <tr>
836 <td rowspan="2" valign="top"><pre class="screen">bool is_negative() const</pre></td>
837 <td>True if and only if duration is negative.</td>
838 </tr>
839 <tr><td><pre class="screen">time_duration td(-1,0,0); 
840 td.is_negative(); // --&gt; true</pre></td></tr>
841 <tr>
842 <td rowspan="2" valign="top"><pre class="screen">bool is_zero() const</pre></td>
843 <td>True if and only if duration is zero.</td>
844 </tr>
845 <tr><td><pre class="screen">time_duration td(0,0,0);
846 td.is_zero(); // --&gt; true</pre></td></tr>
847 <tr>
848 <td rowspan="2" valign="top"><pre class="screen">bool is_positive() const</pre></td>
849 <td>True if and only if duration is positive.</td>
850 </tr>
851 <tr><td><pre class="screen">time_duration td(1,0,0);
852 td.is_positive(); // --&gt; true</pre></td></tr>
853 <tr>
854 <td rowspan="2" valign="top"><pre class="screen">time_duration invert_sign() const</pre></td>
855 <td>Generate a new duration with the sign inverted.</td>
856 </tr>
857 <tr><td><pre class="screen">time_duration td(-1,0,0);
858 td.invert_sign(); // --&gt; 01:00:00</pre></td></tr>
859 <tr>
860 <td rowspan="2" valign="top"><pre class="screen">time_duration abs() const</pre></td>
861 <td>Generate a new duration with the absolute value of the time duration.</td>
862 </tr>
863 <tr>
864 <td><pre class="screen">time_duration td(-1,0,0);
865 td.abs(); // --&gt; 01:00:00</pre></td>
866 <td><pre class="screen">time_duration td(+1,0,0);
867 td.abs(); // --&gt; 01:00:00</pre></td>
868 </tr>
869 <tr>
870 <td rowspan="2" valign="top"><pre class="screen">date_time::time_resolutions time_duration::resolution()</pre></td>
871 <td>Describes the resolution capability of the time_duration class. time_resolutions is an enum of resolution possibilities ranging from seconds to nanoseconds.</td>
872 <td class="auto-generated">&#160;</td>
873 </tr>
874 <tr>
875 <td><pre class="screen">time_duration::resolution() --&gt; nano</pre></td>
876 <td class="auto-generated">&#160;</td>
877 </tr>
878 <tr>
879 <td rowspan="2" valign="top"><pre class="screen">unsigned short time_duration::num_fractional_digits()</pre></td>
880 <td>Returns the number of fractional digits the time resolution has.</td>
881 <td class="auto-generated">&#160;</td>
882 </tr>
883 <tr>
884 <td><pre class="screen">unsigned short secs;
885 secs = time_duration::num_fractional_digits();
886 // 9 for nano, 6 for micro, etc.</pre></td>
887 <td class="auto-generated">&#160;</td>
888 </tr>
889 <tr>
890 <td rowspan="2" valign="top"><pre class="screen">boost::int64_t time_duration::ticks_per_second()</pre></td>
891 <td>Return the number of ticks in a second.  For example, if the duration supports nanoseconds then the returned result will be 1,000,000,000 (1e+9).</td>
892 <td class="auto-generated">&#160;</td>
893 </tr>
894 <tr>
895 <td><pre class="screen">std::cout &lt;&lt; time_duration::ticks_per_second();</pre></td>
896 <td class="auto-generated">&#160;</td>
897 </tr>
898 <tr>
899 <td rowspan="2" valign="top"><pre class="screen">boost::int64_t ticks()</pre></td>
900 <td>Return the raw count of the duration type (will give unpredictable results if calling <code class="computeroutput">time_duration</code> is a <code class="computeroutput">special_value</code>).</td>
901 <td class="auto-generated">&#160;</td>
902 </tr>
903 <tr>
904 <td><pre class="screen">time_duration td(0,0,0, 1000);
905 td.ticks() // --&gt; 1000</pre></td>
906 <td class="auto-generated">&#160;</td>
907 </tr>
908 <tr>
909 <td rowspan="2" valign="top"><pre class="screen">time_duration time_duration::unit()</pre></td>
910 <td>Return smallest possible unit of duration type (1 nanosecond).</td>
911 <td class="auto-generated">&#160;</td>
912 </tr>
913 <tr>
914 <td><pre class="screen">time_duration::unit() --&gt; time_duration(0,0,0,1)</pre></td>
915 <td class="auto-generated">&#160;</td>
916 </tr>
917 <tr>
918 <td rowspan="2" valign="top"><pre class="screen">bool is_neg_infinity() const</pre></td>
919 <td>Returns true if time_duration is negative infinity</td>
920 <td class="auto-generated">&#160;</td>
921 </tr>
922 <tr>
923 <td><pre class="screen">time_duration td(neg_infin);
924 td.is_neg_infinity(); // --&gt; true</pre></td>
925 <td class="auto-generated">&#160;</td>
926 </tr>
927 <tr>
928 <td rowspan="2" valign="top"><pre class="screen">bool is_pos_infinity() const</pre></td>
929 <td>Returns true if time_duration is positive infinity</td>
930 <td class="auto-generated">&#160;</td>
931 </tr>
932 <tr>
933 <td><pre class="screen">time_duration td(pos_infin); 
934 td.is_pos_infinity(); // --&gt; true</pre></td>
935 <td class="auto-generated">&#160;</td>
936 </tr>
937 <tr>
938 <td rowspan="2" valign="top"><pre class="screen">bool is_not_a_date_time() const</pre></td>
939 <td>Returns true if value is not a time</td>
940 <td class="auto-generated">&#160;</td>
941 </tr>
942 <tr>
943 <td><pre class="screen">time_duration td(not_a_date_time);
944 td.is_not_a_date_time(); // --&gt; true</pre></td>
945 <td class="auto-generated">&#160;</td>
946 </tr>
947 <tr>
948 <td rowspan="2" valign="top"><pre class="screen">bool is_special() const</pre></td>
949 <td>Returns true if time_duration is any <code class="computeroutput">special_value</code>
950 </td>
951 <td class="auto-generated">&#160;</td>
952 </tr>
953 <tr>
954 <td><pre class="screen">time_duration td(pos_infin); 
955 time_duration td2(not_a_date_time); 
956 time_duration td3(2,5,10);
957 td.is_special(); // --&gt; true
958 td2.is_special(); // --&gt; true
959 td3.is_special(); // --&gt; false</pre></td>
960 <td class="auto-generated">&#160;</td>
961 </tr>
962 </tbody>
963 </table></div>
964 <p>
965   </p>
966 <a name="time_duration_to_string"></a><h4>
967 <a name="id-1.3.14.9.11.35"></a>Conversion To String</h4>
968 <p>
969     </p>
970 <div class="informaltable"><table class="table">
971 <colgroup>
972 <col>
973 <col>
974 </colgroup>
975 <thead>
976 <tr>
977 <th rowspan="2" valign="top">Syntax</th>
978 <th>Description</th>
979 </tr>
980 <tr><th>Example</th></tr>
981 </thead>
982 <tbody>
983 <tr>
984 <td rowspan="2" valign="top"><pre class="screen">std::string to_simple_string(time_duration)</pre></td>
985 <td>To <code class="computeroutput">HH:MM:SS.fffffffff</code> were <code class="computeroutput">fff</code> is fractional seconds that are only included if non-zero.</td>
986 </tr>
987 <tr><td><pre class="screen">10:00:01.123456789</pre></td></tr>
988 <tr>
989 <td rowspan="2" valign="top"><pre class="screen">std::string to_iso_string(time_duration)</pre></td>
990 <td>Convert to form <code class="computeroutput">HHMMSS,fffffffff</code>.</td>
991 </tr>
992 <tr><td><pre class="screen">100001,123456789</pre></td></tr>
993 </tbody>
994 </table></div>
995 <p>
996   </p>
997 <a name="time_duration_operators"></a><h4>
998 <a name="id-1.3.14.9.11.38"></a>Operators</h4>
999 <p>
1000     </p>
1001 <div class="informaltable"><table class="table">
1002 <colgroup>
1003 <col>
1004 <col>
1005 </colgroup>
1006 <thead>
1007 <tr>
1008 <th rowspan="2" valign="top">Syntax</th>
1009 <th>Description</th>
1010 </tr>
1011 <tr><th>Example</th></tr>
1012 </thead>
1013 <tbody>
1014 <tr>
1015 <td rowspan="2" valign="top"><pre class="screen">operator&lt;&lt;, operator&gt;&gt;</pre></td>
1016 <td>Streaming operators. <span class="strong"><strong>Note:</strong></span> As of version 1.33, streaming operations have been greatly improved. See <a class="link" href="date_time_io.html" title="Date Time Input/Output">Date Time IO System</a> for more details (including exceptions and error conditions).</td>
1017 </tr>
1018 <tr><td>
1019 <pre class="screen">time_duration td(0,0,0);
1020 stringstream ss("14:23:11.345678");
1021 ss &gt;&gt; td; 
1022 std::cout &lt;&lt; td; // "14:23:11.345678"
1023   </pre>
1024             </td></tr>
1025 <tr>
1026 <td rowspan="2" valign="top">
1027 <pre class="screen">operator==, operator!=,
1028 operator&gt;, operator&lt;,
1029 operator&gt;=, operator&lt;=</pre>
1030             </td>
1031 <td>A full complement of comparison operators</td>
1032 </tr>
1033 <tr><td><pre class="screen">dd1 == dd2, etc</pre></td></tr>
1034 <tr>
1035 <td rowspan="2" valign="top"><pre class="screen">time_duration operator+(time_duration)</pre></td>
1036 <td>Add durations.</td>
1037 </tr>
1038 <tr><td>
1039 <pre class="screen">time_duration td1(hours(1)+minutes(2));
1040 time_duration td2(seconds(10));
1041 time_duration td3 = td1 + td2;</pre>
1042             </td></tr>
1043 <tr>
1044 <td rowspan="2" valign="top"><pre class="screen">time_duration operator-(time_duration)</pre></td>
1045 <td>Subtract durations.</td>
1046 </tr>
1047 <tr><td>
1048 <pre class="screen">time_duration td1(hours(1)+nanoseconds(2));
1049 time_duration td2 = td1 - minutes(1);</pre>
1050             </td></tr>
1051 <tr>
1052 <td rowspan="2" valign="top"><pre class="screen">time_duration operator/(int)</pre></td>
1053 <td>Divide the length of a duration by an integer value. Discards any remainder.</td>
1054 </tr>
1055 <tr><td>
1056 <pre class="screen">hours(3)/2 == time_duration(1,30,0);
1057 nanosecond(3)/2 == nanosecond(1);</pre>
1058             </td></tr>
1059 <tr>
1060 <td rowspan="2" valign="top"><pre class="screen">time_duration operator*(int)</pre></td>
1061 <td>Multiply the length of a duration by an integer value.</td>
1062 </tr>
1063 <tr><td><pre class="screen">hours(3)*2 == hours(6);</pre></td></tr>
1064 </tbody>
1065 </table></div>
1066 <p>
1067   </p>
1068 <a name="time_duration_struct_tm"></a><h4>
1069 <a name="id-1.3.14.9.11.41"></a>Struct tm, time_t, and FILETIME Functions</h4>
1070 <p>Function for converting a time_duration to a <code class="computeroutput">tm</code> struct is provided.</p>
1071 <div class="informaltable"><table class="table">
1072 <colgroup>
1073 <col>
1074 <col>
1075 </colgroup>
1076 <thead>
1077 <tr>
1078 <th rowspan="2" valign="top">Syntax</th>
1079 <th>Description</th>
1080 </tr>
1081 <tr><th>Example</th></tr>
1082 </thead>
1083 <tbody>
1084 <tr>
1085 <td rowspan="2" valign="top"><pre class="screen">tm to_tm(time_duration)</pre></td>
1086 <td>A function for converting a <code class="computeroutput">time_duration</code> object to a <code class="computeroutput">tm</code> struct. The fields: <code class="computeroutput">tm_year</code>, <code class="computeroutput">tm_mon</code>, <code class="computeroutput">tm_mday</code>, <code class="computeroutput">tm_wday</code>, <code class="computeroutput">tm_yday</code> are set to zero. The <code class="computeroutput">tm_isdst</code> field is set to -1.</td>
1087 </tr>
1088 <tr><td>
1089 <pre class="screen">time_duration td(1,2,3);
1090 tm td_tm = to_tm(td);
1091 /* tm_year =&gt; 0
1092    tm_mon  =&gt; 0
1093    tm_mday =&gt; 0
1094    tm_wday =&gt; 0
1095    tm_yday =&gt; 0
1096    tm_hour =&gt; 1
1097    tm_min  =&gt; 2
1098    tm_sec  =&gt; 3
1099    tm_isddst =&gt; -1 */</pre>
1100           </td></tr>
1101 </tbody>
1102 </table></div>
1103 </div>
1104 <div class="section">
1105 <div class="titlepage"><div><div><h3 class="title">
1106 <a name="date_time.posix_time.time_period"></a>Time Period</h3></div></div></div>
1107 <a class="link" href="posix_time.html#time_period_intro">Introduction</a> --
1108   <a class="link" href="posix_time.html#time_period_header">Header</a> --
1109   <a class="link" href="posix_time.html#time_period_constr">Construction</a> --
1110   <a class="link" href="posix_time.html#time_period_mutators">Mutators</a> --
1111   <a class="link" href="posix_time.html#time_period_accessors">Accessors</a> --
1112   <a class="link" href="posix_time.html#time_period_to_string">Conversion To String</a> --
1113   <a class="link" href="posix_time.html#time_period_operators">Operators</a><a name="time_period_intro"></a><h4>
1114 <a name="id-1.3.14.9.12.10"></a>Introduction</h4>
1115 <p>
1116     The class boost::posix_time::time_period provides direct representation for ranges between two times. Periods provide the ability to simplify some types of calculations by simplifying the conditional logic of the program. 
1117   </p>
1118 <p>
1119     A period that is created with beginning and end points being equal, or with a duration of zero, is known as a zero length period. Zero length periods are considered invalid (it is perfectly legal to construct an invalid period). For these periods, the <code class="computeroutput">last</code> point will always be one unit less that the <code class="computeroutput">begin</code> point.
1120   </p>
1121 <p>
1122     The <a class="link" href="examples.html#date_time.examples.time_periods" title="Time Periods">time periods example</a> provides an example of using time periods. 
1123   </p>
1124 <a name="time_period_header"></a><h4>
1125 <a name="id-1.3.14.9.12.15"></a>Header</h4>
1126 <p>
1127     </p>
1128 <pre class="programlisting">#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
1129 or
1130 #include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types</pre>
1131 <p>
1132   </p>
1133 <a name="time_period_constr"></a><h4>
1134 <a name="id-1.3.14.9.12.18"></a>Construction</h4>
1135 <p>
1136     </p>
1137 <div class="informaltable"><table class="table">
1138 <colgroup>
1139 <col>
1140 <col>
1141 </colgroup>
1142 <thead>
1143 <tr>
1144 <th rowspan="2" valign="top">Syntax</th>
1145 <th>Description</th>
1146 </tr>
1147 <tr><th>Example</th></tr>
1148 </thead>
1149 <tbody>
1150 <tr>
1151 <td rowspan="2" valign="top"><pre class="screen">time_period(ptime,
1152             ptime)</pre></td>
1153 <td> Create a period as [begin, end). If end is &lt;= begin then the period will be defined as invalid.</td>
1154 </tr>
1155 <tr><td>
1156 <pre class="screen">date d(2002,Jan,01);
1157 ptime t1(d, seconds(10)); //10 sec after midnight
1158 ptime t2(d, hours(10)); //10 hours after midnight
1159 time_period tp(t1, t2);</pre>
1160             </td></tr>
1161 <tr>
1162 <td rowspan="2" valign="top"><pre class="screen">time_period(ptime, 
1163             time_duration)</pre></td>
1164 <td> Create a period as [begin, begin+len) where end would be begin+len. If len is &lt;= zero then the period will be defined as invalid.</td>
1165 </tr>
1166 <tr><td>
1167 <pre class="screen">date d(2002,Jan,01);
1168 ptime t(d, seconds(10)); //10 sec after midnight
1169 time_period tp(t, hours(3));</pre>
1170             </td></tr>
1171 <tr>
1172 <td rowspan="2" valign="top"><pre class="screen">time_period(time_period rhs)</pre></td>
1173 <td> Copy constructor</td>
1174 </tr>
1175 <tr><td><pre class="screen">time_period tp1(tp);</pre></td></tr>
1176 </tbody>
1177 </table></div>
1178 <p>
1179   </p>
1180 <a name="time_period_mutators"></a><h4>
1181 <a name="id-1.3.14.9.12.21"></a>Mutators</h4>
1182 <p>
1183     </p>
1184 <div class="informaltable"><table class="table">
1185 <colgroup>
1186 <col>
1187 <col>
1188 </colgroup>
1189 <thead>
1190 <tr>
1191 <th rowspan="2" valign="top">Syntax</th>
1192 <th>Description</th>
1193 </tr>
1194 <tr><th>Example</th></tr>
1195 </thead>
1196 <tbody>
1197 <tr>
1198 <td rowspan="2" valign="top"><pre class="screen">time_period shift(time_duration)</pre></td>
1199 <td>Add duration to both begin and end.</td>
1200 </tr>
1201 <tr><td>
1202               <pre class="screen">
1203 time_period tp(ptime(date(2005,Jan,1),hours(1)), hours(2));
1204 tp.shift(minutes(5)); 
1205 // tp == 2005-Jan-01 01:05:00 to 2005-Jan-01 03:05:00
1206              </pre>
1207             </td></tr>
1208 <tr>
1209 <td rowspan="2" valign="top"><pre class="screen">time_period expand(days)</pre></td>
1210 <td>Subtract duration from begin and add duration to end.</td>
1211 </tr>
1212 <tr><td>
1213               <pre class="screen">
1214 time_period tp(ptime(date(2005,Jan,1),hours(1)), hours(2));
1215 tp.expand(minutes(5)); 
1216 // tp == 2005-Jan-01 00:55:00 to 2005-Jan-01 03:05:00
1217              </pre>
1218             </td></tr>
1219 </tbody>
1220 </table></div>
1221 <p>
1222   </p>
1223 <a name="time_period_accessors"></a><h4>
1224 <a name="id-1.3.14.9.12.24"></a>Accessors</h4>
1225 <p>
1226     </p>
1227 <div class="informaltable"><table class="table">
1228 <colgroup>
1229 <col>
1230 <col>
1231 </colgroup>
1232 <thead>
1233 <tr>
1234 <th rowspan="2" valign="top">Syntax</th>
1235 <th>Description</th>
1236 </tr>
1237 <tr><th>Example</th></tr>
1238 </thead>
1239 <tbody>
1240 <tr>
1241 <td rowspan="2" valign="top"><pre class="screen">ptime begin()</pre></td>
1242 <td>Return first time of period.</td>
1243 </tr>
1244 <tr><td>
1245 <pre class="screen">date d(2002,Jan,01);
1246 ptime t1(d, seconds(10)); //10 sec after midnight
1247 ptime t2(d, hours(10)); //10 hours after midnight
1248 time_period tp(t1, t2);
1249 tp.begin(); // --&gt; 2002-Jan-01 00:00:10</pre>
1250             </td></tr>
1251 <tr>
1252 <td rowspan="2" valign="top"><pre class="screen">ptime last()</pre></td>
1253 <td>Return last time in the period</td>
1254 </tr>
1255 <tr><td>
1256 <pre class="screen">date d(2002,Jan,01);
1257 ptime t1(d, seconds(10)); //10 sec after midnight
1258 ptime t2(d, hours(10)); //10 hours after midnight
1259 time_period tp(t1, t2);
1260 tp.last();// --&gt; 2002-Jan-01 09:59:59.999999999</pre>
1261             </td></tr>
1262 <tr>
1263 <td rowspan="2" valign="top"><pre class="screen">ptime end()</pre></td>
1264 <td> Return one past the last in period</td>
1265 </tr>
1266 <tr><td>
1267 <pre class="screen">date d(2002,Jan,01);
1268 ptime t1(d, seconds(10)); //10 sec after midnight
1269 ptime t2(d, hours(10)); //10 hours after midnight
1270 time_period tp(t1, t2);
1271 tp.last(); // --&gt; 2002-Jan-01 10:00:00</pre>
1272             </td></tr>
1273 <tr>
1274 <td rowspan="2" valign="top"><pre class="screen">time_duration length()</pre></td>
1275 <td>Return the length of the time period.</td>
1276 </tr>
1277 <tr><td>
1278 <pre class="screen">date d(2002,Jan,01);
1279 ptime t1(d); //midnight
1280 time_period tp(t1, hours(1));
1281 tp.length() --&gt; 1 hour</pre>
1282             </td></tr>
1283 <tr>
1284 <td rowspan="2" valign="top"><pre class="screen">bool is_null()</pre></td>
1285 <td>True if period is not well formed. eg: end is less than or equal to begin.</td>
1286 </tr>
1287 <tr><td>
1288 <pre class="screen">date d(2002,Jan,01);
1289 ptime t1(d, hours(12)); // noon on Jan 1st
1290 ptime t2(d, hours(9)); // 9am on Jan 1st
1291 time_period tp(t1, t2);
1292 tp.is_null(); // true</pre>
1293             </td></tr>
1294 <tr>
1295 <td rowspan="2" valign="top"><pre class="screen">bool contains(ptime)</pre></td>
1296 <td>True if ptime is within the period. Zero length periods cannot contain any points.</td>
1297 </tr>
1298 <tr><td>
1299 <pre class="screen">date d(2002,Jan,01);
1300 ptime t1(d, seconds(10)); //10 sec after midnight
1301 ptime t2(d, hours(10)); //10 hours after midnight
1302 ptime t3(d, hours(2)); //2 hours after midnight
1303 time_period tp(t1, t2); 
1304 tp.contains(t3); // true
1305 time_period tp2(t1, t1);
1306 tp2.contains(t1); // false</pre>
1307             </td></tr>
1308 <tr>
1309 <td rowspan="2" valign="top"><pre class="screen">bool contains(time_period)</pre></td>
1310 <td>True if period is within the period</td>
1311 </tr>
1312 <tr><td>
1313 <pre class="screen">time_period tp1(ptime(d,hours(1)), 
1314                 ptime(d,hours(12)));
1315 time_period tp2(ptime(d,hours(2)), 
1316                 ptime(d,hours(4)));
1317 tp1.contains(tp2); // --&gt; true
1318 tp2.contains(tp1); // --&gt; false</pre>
1319             </td></tr>
1320 <tr>
1321 <td rowspan="2" valign="top"><pre class="screen">bool intersects(time_period)</pre></td>
1322 <td> True if periods overlap</td>
1323 </tr>
1324 <tr><td>
1325 <pre class="screen">time_period tp1(ptime(d,hours(1)),
1326                 ptime(d,hours(12)));
1327 time_period tp2(ptime(d,hours(2)), 
1328                 ptime(d,hours(4)));
1329 tp2.intersects(tp1); // --&gt; true</pre>
1330             </td></tr>
1331 <tr>
1332 <td rowspan="2" valign="top"><pre class="screen">time_period intersection(time_period)</pre></td>
1333 <td>Calculate the intersection of 2 periods. Null if no intersection.</td>
1334 </tr>
1335 <tr><td>&#160;</td></tr>
1336 <tr>
1337 <td rowspan="2" valign="top"><pre class="screen">time_period merge(time_period)</pre></td>
1338 <td>Returns union of two periods. Null if no intersection.</td>
1339 </tr>
1340 <tr><td>&#160;</td></tr>
1341 <tr>
1342 <td rowspan="2" valign="top"><pre class="screen">time_period span(time_period)</pre></td>
1343 <td>Combines two periods and any gap between them such that begin = min(p1.begin, p2.begin) and end = max(p1.end , p2.end).</td>
1344 </tr>
1345 <tr><td>&#160;</td></tr>
1346 </tbody>
1347 </table></div>
1348 <p>
1349   </p>
1350 <a name="time_period_to_string"></a><h4>
1351 <a name="id-1.3.14.9.12.27"></a>Conversion To String</h4>
1352 <p>
1353     </p>
1354 <div class="informaltable"><table class="table">
1355 <colgroup>
1356 <col>
1357 <col>
1358 </colgroup>
1359 <thead>
1360 <tr>
1361 <th rowspan="2" valign="top">Syntax</th>
1362 <th>Description</th>
1363 </tr>
1364 <tr><th>Example</th></tr>
1365 </thead>
1366 <tbody>
1367 <tr>
1368 <td rowspan="2" valign="top"><pre class="screen">std::string 
1369   to_simple_string(time_period dp)</pre></td>
1370 <td>To <code class="computeroutput">[YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff]</code> string where <code class="computeroutput">mmm</code> is 3 char month name.</td>
1371 </tr>
1372 <tr><td><pre class="screen">[2002-Jan-01 01:25:10.000000001/
1373                 2002-Jan-31 01:25:10.123456789]
1374 // string occupies one line</pre></td></tr>
1375 </tbody>
1376 </table></div>
1377 <p>
1378   </p>
1379 <a name="time_period_operators"></a><h4>
1380 <a name="id-1.3.14.9.12.30"></a>Operators</h4>
1381 <p>
1382     </p>
1383 <div class="informaltable"><table class="table">
1384 <colgroup>
1385 <col>
1386 <col>
1387 </colgroup>
1388 <thead>
1389 <tr>
1390 <th rowspan="2" valign="top">Syntax</th>
1391 <th>Description</th>
1392 </tr>
1393 <tr><th>Example</th></tr>
1394 </thead>
1395 <tbody>
1396 <tr>
1397 <td rowspan="2" valign="top"><pre class="screen">operator&lt;&lt;</pre></td>
1398 <td>Output streaming operator for time duration. Uses facet to output [date time_of_day/date time_of_day]. The default is format is <code class="computeroutput">[YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff]</code> string where <code class="computeroutput">mmm</code> is 3 char month name and the fractional seconds are left out when zero.</td>
1399 </tr>
1400 <tr><td><pre class="screen">[2002-Jan-01 01:25:10.000000001/ \
1401     2002-Jan-31 01:25:10.123456789]</pre></td></tr>
1402 <tr>
1403 <td rowspan="2" valign="top"><pre class="screen">operator&gt;&gt;</pre></td>
1404 <td>Input streaming operator for time duration. Uses facet to read [date time_of_day/date time_of_day]. The default is format is <code class="computeroutput">[YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff]</code> string where <code class="computeroutput">mmm</code> is 3 char month name and the fractional seconds are left out when zero.</td>
1405 </tr>
1406 <tr><td><pre class="screen">[2002-Jan-01 01:25:10.000000001/ \
1407     2002-Jan-31 01:25:10.123456789]</pre></td></tr>
1408 <tr>
1409 <td rowspan="2" valign="top"><pre class="screen">operator==, operator!=</pre></td>
1410 <td>Equality operators. Periods are equal if p1.begin == p2.begin &amp;&amp; p1.last == p2.last</td>
1411 </tr>
1412 <tr><td><pre class="screen">if (tp1 == tp2) {...</pre></td></tr>
1413 <tr>
1414 <td rowspan="2" valign="top"><pre class="screen">operator&lt;</pre></td>
1415 <td>Ordering with no overlap. True if tp1.end() less than tp2.begin()</td>
1416 </tr>
1417 <tr><td><pre class="screen">if (tp1 &lt; tp2) {...</pre></td></tr>
1418 <tr>
1419 <td rowspan="2" valign="top"><pre class="screen">operator&gt;</pre></td>
1420 <td>Ordering with no overlap. True if tp1.begin() greater than tp2.end()</td>
1421 </tr>
1422 <tr><td><pre class="screen">if (tp1 &gt; tp2) {... etc</pre></td></tr>
1423 <tr>
1424 <td rowspan="2" valign="top"><pre class="screen">operator&lt;=, operator&gt;=</pre></td>
1425 <td>Defined in terms of the other operators.</td>
1426 </tr>
1427 <tr><td>&#160;</td></tr>
1428 </tbody>
1429 </table></div>
1430 <p>
1431   </p>
1432 </div>
1433 <div class="section">
1434 <div class="titlepage"><div><div><h3 class="title">
1435 <a name="date_time.posix_time.time_iterators"></a>Time Iterators</h3></div></div></div>
1436 <a class="link" href="posix_time.html#time_iter_intro">Introduction</a> --
1437   <a class="link" href="posix_time.html#time_iter_header">Header</a> --
1438   <a class="link" href="posix_time.html#time_iter_overview">Overview</a> --
1439   <a class="link" href="posix_time.html#time_iter_operators">Operators</a><a name="time_iter_intro"></a><h4>
1440 <a name="id-1.3.14.9.13.7"></a>Introduction</h4>
1441 <p>
1442     Time iterators provide a mechanism for iteration through times. Time iterators are similar to <a href="http://www.sgi.com/tech/stl/BidirectionalIterator.html" target="_top">Bidirectional Iterators</a>. However, time_iterators are different than standard iterators in that there is no underlying sequence, just a calculation function. In addition, time_iterators are directly comparable against instances of <a class="link" href="posix_time.html#date_time.posix_time.ptime_class" title="Ptime">class ptime</a>. Thus a second iterator for the end point of the iteration is not required, but rather a point in time can be used directly. For example, the following code iterates using a 15 minute iteration interval. The <a class="link" href="examples.html#date_time.examples.print_hours" title="Print Hours">print hours</a> example also illustrates the use of the time_iterator. 
1443   </p>
1444 <p>
1445     </p>
1446 <pre class="programlisting">
1447       
1448         #include "boost/date_time/posix_time/posix_time.hpp"
1449         #include &lt;iostream&gt;
1450
1451
1452         int
1453         main()
1454         {
1455           using namespace boost::gregorian;
1456           using namespace boost::posix_time;
1457           date d(2000,Jan,20);
1458           ptime start(d);
1459           ptime end = start + hours(1);
1460           time_iterator titr(start,minutes(15)); //increment by 15 minutes
1461           //produces 00:00:00, 00:15:00, 00:30:00, 00:45:00
1462           while (titr &lt; end) {
1463             std::cout &lt;&lt; to_simple_string(*titr) &lt;&lt; std::endl;
1464             ++titr;
1465           }
1466           std::cout &lt;&lt; "Now backward" &lt;&lt; std::endl;
1467           //produces 01:00:00, 00:45:00, 00:30:00, 00:15:00
1468           while (titr &gt; start) {
1469             std::cout &lt;&lt; to_simple_string(*titr) &lt;&lt; std::endl;
1470             --titr;
1471           }
1472         }
1473       
1474     </pre>
1475 <p>
1476   </p>
1477 <a name="time_iter_header"></a><h4>
1478 <a name="id-1.3.14.9.13.11"></a>Header</h4>
1479 <p>
1480     </p>
1481 <pre class="programlisting">#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
1482 or
1483 #include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types</pre>
1484 <p>
1485   </p>
1486 <a name="time_iter_overview"></a><h4>
1487 <a name="id-1.3.14.9.13.14"></a>Overview</h4>
1488 <p>
1489     </p>
1490 <div class="informaltable"><table class="table">
1491 <colgroup>
1492 <col>
1493 <col>
1494 </colgroup>
1495 <thead>
1496 <tr>
1497 <th rowspan="2" valign="top">Class</th>
1498 <th>Description</th>
1499 </tr>
1500 <tr><th>Construction Parameters</th></tr>
1501 </thead>
1502 <tbody>
1503 <tr>
1504 <td rowspan="2" valign="top"><pre class="screen">time_iterator</pre></td>
1505 <td>Iterate incrementing by the specified duration.</td>
1506 </tr>
1507 <tr><td><pre class="screen">ptime start_time, time_duration increment</pre></td></tr>
1508 </tbody>
1509 </table></div>
1510 <p>
1511   </p>
1512 <a name="time_iter_operators"></a><h4>
1513 <a name="id-1.3.14.9.13.17"></a>Operators</h4>
1514 <p>
1515     </p>
1516 <div class="informaltable"><table class="table">
1517 <colgroup>
1518 <col>
1519 <col>
1520 </colgroup>
1521 <thead>
1522 <tr>
1523 <th rowspan="2" valign="top">Syntax</th>
1524 <th>Description</th>
1525 </tr>
1526 <tr><th>Example</th></tr>
1527 </thead>
1528 <tbody>
1529 <tr>
1530 <td rowspan="2" valign="top">
1531 <pre class="screen">operator==(const ptime&amp; rhs),
1532 operator!=(const ptime&amp; rhs),
1533 operator&gt;, operator&lt;,
1534 operator&gt;=, operator&lt;=</pre>
1535             </td>
1536 <td>A full complement of comparison operators</td>
1537 </tr>
1538 <tr><td>
1539 <pre class="screen">date d(2002,Jan,1);
1540 ptime start_time(d, hours(1));
1541 //increment by 10 minutes
1542 time_iterator titr(start_time, minutes(10));
1543 ptime end_time = start_time + hours(2);
1544 if (titr == end_time) // false
1545 if (titr != end_time) // true
1546 if (titr &gt;= end_time) // false
1547 if (titr &lt;= end_time) // true</pre>
1548             </td></tr>
1549 <tr>
1550 <td rowspan="2" valign="top"><pre class="screen">prefix increment</pre></td>
1551 <td>Increment the iterator by the specified duration.</td>
1552 </tr>
1553 <tr><td>
1554 <pre class="screen">//increment by 10 milli seconds
1555 time_iterator titr(start_time, milliseconds(10));
1556 ++titr; // == start_time + 10 milliseconds</pre>
1557             </td></tr>
1558 <tr>
1559 <td rowspan="2" valign="top"><pre class="screen">prefix decrement</pre></td>
1560 <td>Decrement the iterator by the specified time duration.</td>
1561 </tr>
1562 <tr><td><pre class="screen">time_duration td(1,2,3);
1563 time_iterator titr(start_time, td);
1564 --titr; // == start_time - 01:02:03</pre></td></tr>
1565 </tbody>
1566 </table></div>
1567 <p>
1568   </p>
1569 </div>
1570 </div>
1571 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
1572 <td align="left"></td>
1573 <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
1574     <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
1575 </div></td>
1576 </tr></table>
1577 <hr>
1578 <div class="spirit-nav">
1579 <a accesskey="p" href="gregorian.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../date_time.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="local_time.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
1580 </div>
1581 </body>
1582 </html>