| 1 | <html> |
|---|
| 2 | <head> |
|---|
| 3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
|---|
| 4 | <title>Class template period</title> |
|---|
| 5 | <link rel="stylesheet" href="boostbook.css" type="text/css"> |
|---|
| 6 | <meta name="generator" content="DocBook XSL Stylesheets V1.69.1"> |
|---|
| 7 | <link rel="start" href="index.html" title="The Boost C++ Libraries"> |
|---|
| 8 | <link rel="up" href="date_time/doxy.html#id2434012" title="Header <boost/date_time/period.hpp>"> |
|---|
| 9 | <link rel="prev" href="id2483937.html" title="Type ymd_order_spec"> |
|---|
| 10 | <link rel="next" href="period_formatter.html" title="Class template period_formatter"> |
|---|
| 11 | </head> |
|---|
| 12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
|---|
| 13 | <table cellpadding="2" width="100%"> |
|---|
| 14 | <td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../boost.png"></td> |
|---|
| 15 | <td align="center"><a href="../../index.htm">Home</a></td> |
|---|
| 16 | <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> |
|---|
| 17 | <td align="center"><a href="../../people/people.htm">People</a></td> |
|---|
| 18 | <td align="center"><a href="../../more/faq.htm">FAQ</a></td> |
|---|
| 19 | <td align="center"><a href="../../more/index.htm">More</a></td> |
|---|
| 20 | </table> |
|---|
| 21 | <hr> |
|---|
| 22 | <div class="spirit-nav"> |
|---|
| 23 | <a accesskey="p" href="id2483937.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="date_time/doxy.html#id2434012"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="period_formatter.html"><img src="images/next.png" alt="Next"></a> |
|---|
| 24 | </div> |
|---|
| 25 | <div class="refentry" lang="en"> |
|---|
| 26 | <a name="period"></a><div class="titlepage"></div> |
|---|
| 27 | <div class="refnamediv"> |
|---|
| 28 | <h2><span class="refentrytitle">Class template period</span></h2> |
|---|
| 29 | <p>boost::date_time::period — Provides generalized period type useful in date-time systems. </p> |
|---|
| 30 | </div> |
|---|
| 31 | <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> |
|---|
| 32 | <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> point_rep, <span class="bold"><strong>typename</strong></span> duration_rep> |
|---|
| 33 | <span class="bold"><strong>class</strong></span> period { |
|---|
| 34 | <span class="bold"><strong>public</strong></span>: |
|---|
| 35 | <span class="emphasis"><em>// types</em></span> |
|---|
| 36 | <span class="bold"><strong>typedef</strong></span> point_rep point_type; |
|---|
| 37 | <span class="bold"><strong>typedef</strong></span> duration_rep duration_type; |
|---|
| 38 | |
|---|
| 39 | <span class="emphasis"><em>// <a href="period.html#periodconstruct-copy-destruct">construct/copy/destruct</a></em></span> |
|---|
| 40 | <a href="period.html#id2410155-bb">period</a>(point_rep, point_rep); |
|---|
| 41 | <a href="period.html#id2410192-bb">period</a>(point_rep, duration_rep); |
|---|
| 42 | |
|---|
| 43 | <span class="emphasis"><em>// <a href="period.html#id2458307-bb">public member functions</a></em></span> |
|---|
| 44 | <span class="type">point_rep</span> <a href="period.html#id2458311-bb">begin</a>() <span class="bold"><strong>const</strong></span>; |
|---|
| 45 | <span class="type">point_rep</span> <a href="period.html#id2442552-bb">end</a>() <span class="bold"><strong>const</strong></span>; |
|---|
| 46 | <span class="type">point_rep</span> <a href="period.html#id2442568-bb">last</a>() <span class="bold"><strong>const</strong></span>; |
|---|
| 47 | <span class="type">duration_rep</span> <a href="period.html#id2442584-bb">length</a>() <span class="bold"><strong>const</strong></span>; |
|---|
| 48 | <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="period.html#id2477874-bb">is_null</a>() <span class="bold"><strong>const</strong></span>; |
|---|
| 49 | <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="period.html#id2477891-bb"><span class="bold"><strong>operator</strong></span>==</a>(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> &) <span class="bold"><strong>const</strong></span>; |
|---|
| 50 | <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="period.html#id2417421-bb"><span class="bold"><strong>operator</strong></span><</a>(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> &) <span class="bold"><strong>const</strong></span>; |
|---|
| 51 | <span class="type"><span class="bold"><strong>void</strong></span></span> <a href="period.html#id2417451-bb">shift</a>(<span class="bold"><strong>const</strong></span> duration_rep &) ; |
|---|
| 52 | <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="period.html#id2457178-bb">contains</a>(<span class="bold"><strong>const</strong></span> point_rep &) <span class="bold"><strong>const</strong></span>; |
|---|
| 53 | <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="period.html#id2457205-bb">contains</a>(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> &) <span class="bold"><strong>const</strong></span>; |
|---|
| 54 | <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="period.html#id2452458-bb">intersects</a>(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> &) <span class="bold"><strong>const</strong></span>; |
|---|
| 55 | <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="period.html#id2453088-bb">is_adjacent</a>(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> &) <span class="bold"><strong>const</strong></span>; |
|---|
| 56 | <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="period.html#id2453119-bb">is_before</a>(<span class="bold"><strong>const</strong></span> point_rep &) <span class="bold"><strong>const</strong></span>; |
|---|
| 57 | <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="period.html#id2393884-bb">is_after</a>(<span class="bold"><strong>const</strong></span> point_rep &) <span class="bold"><strong>const</strong></span>; |
|---|
| 58 | <span class="type"><a href="period.html" title="Class template period">period</a></span> <a href="period.html#id2393911-bb">intersection</a>(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> &) <span class="bold"><strong>const</strong></span>; |
|---|
| 59 | <span class="type"><a href="period.html" title="Class template period">period</a></span> <a href="period.html#id2432541-bb">merge</a>(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> &) <span class="bold"><strong>const</strong></span>; |
|---|
| 60 | <span class="type"><a href="period.html" title="Class template period">period</a></span> <a href="period.html#id2472159-bb">span</a>(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> &) <span class="bold"><strong>const</strong></span>; |
|---|
| 61 | };</pre></div> |
|---|
| 62 | <div class="refsect1" lang="en"> |
|---|
| 63 | <a name="id2646299"></a><h2>Description</h2> |
|---|
| 64 | <p>This template uses a class to represent a time point within the period and another class to represent a duration. As a result, this class is not appropriate for use when the number and duration representation are the same (eg: in the regular number domain).</p> |
|---|
| 65 | <p>A period can be specified by providing either the begining point and a duration or the begining point and the end point( end is NOT part of the period but 1 unit past it. A period will be "invalid" if either end_point <= begin_point or the given duration is <= 0. Any valid period will return false for is_null().</p> |
|---|
| 66 | <p>Zero length periods are also considered invalid. Zero length periods are periods where the begining and end points are the same, or, the given duration is zero. For a zero length period, the last point will be one unit less than the begining point.</p> |
|---|
| 67 | <p>In the case that the begin and last are the same, the period has a length of one unit.</p> |
|---|
| 68 | <p>The best way to handle periods is usually to provide a begining point and a duration. So, day1 + 7 days is a week period which includes all of the first day and 6 more days (eg: Sun to Sat). </p> |
|---|
| 69 | <div class="refsect2" lang="en"> |
|---|
| 70 | <a name="id2646334"></a><h3> |
|---|
| 71 | <a name="periodconstruct-copy-destruct"></a><code class="computeroutput">period</code> construct/copy/destruct</h3> |
|---|
| 72 | <div class="orderedlist"><ol type="1"> |
|---|
| 73 | <li> |
|---|
| 74 | <pre class="literallayout"><a name="id2410155-bb"></a>period(point_rep first_point, point_rep end_point);</pre> |
|---|
| 75 | <p>If end <= begin then the period will be invalid </p> |
|---|
| 76 | </li> |
|---|
| 77 | <li> |
|---|
| 78 | <pre class="literallayout"><a name="id2410192-bb"></a>period(point_rep first_point, duration_rep len);</pre> |
|---|
| 79 | <p>If len is <= 0 then the period will be invalid </p> |
|---|
| 80 | </li> |
|---|
| 81 | </ol></div> |
|---|
| 82 | </div> |
|---|
| 83 | <div class="refsect2" lang="en"> |
|---|
| 84 | <a name="id2646392"></a><h3> |
|---|
| 85 | <a name="id2458307-bb"></a><code class="computeroutput">period</code> public member functions</h3> |
|---|
| 86 | <div class="orderedlist"><ol type="1"> |
|---|
| 87 | <li><pre class="literallayout"><span class="type">point_rep</span> <a name="id2458311-bb"></a>begin() <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 88 | <li><pre class="literallayout"><span class="type">point_rep</span> <a name="id2442552-bb"></a>end() <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 89 | <li><pre class="literallayout"><span class="type">point_rep</span> <a name="id2442568-bb"></a>last() <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 90 | <li><pre class="literallayout"><span class="type">duration_rep</span> <a name="id2442584-bb"></a>length() <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 91 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2477874-bb"></a>is_null() <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 92 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2477891-bb"></a><span class="bold"><strong>operator</strong></span>==(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> & rhs) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 93 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2417421-bb"></a><span class="bold"><strong>operator</strong></span><(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> & rhs) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 94 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id2417451-bb"></a>shift(<span class="bold"><strong>const</strong></span> duration_rep & d) ;</pre></li> |
|---|
| 95 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2457178-bb"></a>contains(<span class="bold"><strong>const</strong></span> point_rep & point) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 96 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2457205-bb"></a>contains(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> & other) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 97 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2452458-bb"></a>intersects(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> & other) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 98 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2453088-bb"></a>is_adjacent(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> & other) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 99 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2453119-bb"></a>is_before(<span class="bold"><strong>const</strong></span> point_rep & point) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 100 | <li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2393884-bb"></a>is_after(<span class="bold"><strong>const</strong></span> point_rep & point) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 101 | <li><pre class="literallayout"><span class="type"><a href="period.html" title="Class template period">period</a></span> <a name="id2393911-bb"></a>intersection(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> & other) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 102 | <li><pre class="literallayout"><span class="type"><a href="period.html" title="Class template period">period</a></span> <a name="id2432541-bb"></a>merge(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> & other) <span class="bold"><strong>const</strong></span>;</pre></li> |
|---|
| 103 | <li> |
|---|
| 104 | <pre class="literallayout"><span class="type"><a href="period.html" title="Class template period">period</a></span> <a name="id2472159-bb"></a>span(<span class="bold"><strong>const</strong></span> <a href="period.html" title="Class template period">period</a> & other) <span class="bold"><strong>const</strong></span>;</pre> |
|---|
| 105 | <p>Combines two periods and any gap between them such that start = min(p1.start, p2.start) end = max(p1.end , p2.end) </p> |
|---|
| 106 | <pre class="programlisting"> [---p1---) |
|---|
| 107 | [---p2---) |
|---|
| 108 | result: |
|---|
| 109 | [-----------p3----------) |
|---|
| 110 | * |
|---|
| 111 | </pre> |
|---|
| 112 | </li> |
|---|
| 113 | </ol></div> |
|---|
| 114 | </div> |
|---|
| 115 | </div> |
|---|
| 116 | </div> |
|---|
| 117 | <table width="100%"><tr> |
|---|
| 118 | <td align="left"></td> |
|---|
| 119 | <td align="right"><small>Copyright © 2001-2005 CrystalClear Software, Inc</small></td> |
|---|
| 120 | </tr></table> |
|---|
| 121 | <hr> |
|---|
| 122 | <div class="spirit-nav"> |
|---|
| 123 | <a accesskey="p" href="id2483937.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="date_time/doxy.html#id2434012"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="period_formatter.html"><img src="images/next.png" alt="Next"></a> |
|---|
| 124 | </div> |
|---|
| 125 | </body> |
|---|
| 126 | </html> |
|---|