<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Class template date_duration</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../date_time/doxy.html#header.boost.date_time.date_duration_hpp" title="Header &lt;boost/date_time/date_duration.hpp&gt;">
<link rel="prev" href="day_clock.html" title="Class template day_clock">
<link rel="next" href="duration_traits_long.html" title="Struct duration_traits_long">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="day_clock.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.date_duration_hpp"><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="duration_traits_long.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.date_time.date_duration"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template date_duration</span></h2>
<p>boost::date_time::date_duration &#8212; Duration type with date level resolution. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../date_time/doxy.html#header.boost.date_time.date_duration_hpp" title="Header &lt;boost/date_time/date_duration.hpp&gt;">boost/date_time/date_duration.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> duration_rep_traits<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">:</span> <span class="keyword">private</span> boost::less_than_comparable1&lt; date_duration&lt; duration_rep_traits &gt;, boost::equality_comparable1&lt; date_duration&lt; duration_rep_traits &gt;, boost::addable1&lt; date_duration&lt; duration_rep_traits &gt;, boost::subtractable1&lt; date_duration&lt; duration_rep_traits &gt;, boost::dividable2&lt; date_duration&lt; duration_rep_traits &gt;, int &gt; &gt; &gt; &gt; &gt;
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">duration_rep_traits</span><span class="special">::</span><span class="identifier">int_type</span>  <a name="boost.date_time.date_duration.duration_rep_type"></a><span class="identifier">duration_rep_type</span><span class="special">;</span>
  <span class="keyword">typedef</span> <span class="identifier">duration_rep_traits</span><span class="special">::</span><span class="identifier">impl_type</span> <a name="boost.date_time.date_duration.duration_rep"></a><span class="identifier">duration_rep</span><span class="special">;</span>     

  <span class="comment">// <a class="link" href="date_duration.html#boost.date_time.date_durationconstruct-copy-destruct">construct/copy/destruct</a></span>
  <span class="keyword">explicit</span> <a class="link" href="date_duration.html#idp113239072-bb"><span class="identifier">date_duration</span></a><span class="special">(</span><span class="identifier">duration_rep</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="date_duration.html#idp105140336-bb"><span class="identifier">date_duration</span></a><span class="special">(</span><span class="identifier">special_values</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="date_duration.html#idp38444208-bb"><span class="identifier">date_duration</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a><span class="special">&lt;</span> <span class="identifier">duration_rep_traits</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="date_duration.html#idp100962896-bb">public member functions</a></span>
  <span class="identifier">duration_rep</span> <a class="link" href="date_duration.html#idp99951696-bb"><span class="identifier">get_rep</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="date_duration.html#idp98385808-bb"><span class="identifier">is_special</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">duration_rep_type</span> <a class="link" href="date_duration.html#idp107058784-bb"><span class="identifier">days</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="date_duration.html#idp107028336-bb"><span class="keyword">operator</span><span class="special">==</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="date_duration.html#idp55417152-bb"><span class="keyword">operator</span><span class="special">&lt;</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span> <a class="link" href="date_duration.html#idp70186608-bb"><span class="keyword">operator</span><span class="special">-=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span> <a class="link" href="date_duration.html#idp105040032-bb"><span class="keyword">operator</span><span class="special">+=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <a class="link" href="date_duration.html#idp96827328-bb"><span class="keyword">operator</span><span class="special">-</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span> <a class="link" href="date_duration.html#idp74369712-bb"><span class="keyword">operator</span><span class="special">/=</span></a><span class="special">(</span><span class="keyword">int</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="date_duration.html#idp110799904-bb"><span class="identifier">is_negative</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="date_duration.html#idp44073248-bb">public static functions</a></span>
  <span class="keyword">static</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <a class="link" href="date_duration.html#idp44073808-bb"><span class="identifier">unit</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idp182928224"></a><h2>Description</h2>
<div class="refsect2">
<a name="idp182928640"></a><h3>
<a name="boost.date_time.date_durationconstruct-copy-destruct"></a><code class="computeroutput">date_duration</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="idp113239072-bb"></a><span class="identifier">date_duration</span><span class="special">(</span><span class="identifier">duration_rep</span> day_count<span class="special">)</span><span class="special">;</span></pre>Construct from a day count. </li>
<li class="listitem">
<pre class="literallayout"><a name="idp105140336-bb"></a><span class="identifier">date_duration</span><span class="special">(</span><span class="identifier">special_values</span> sv<span class="special">)</span><span class="special">;</span></pre>
<p>construct from special_values - only works when instantiated with <code class="computeroutput"><a class="link" href="duration_traits_adapted.html" title="Struct duration_traits_adapted">duration_traits_adapted</a></code> </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idp38444208-bb"></a><span class="identifier">date_duration</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a><span class="special">&lt;</span> <span class="identifier">duration_rep_traits</span> <span class="special">&gt;</span> <span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>Construct from another <code class="computeroutput"><a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a></code> (Copy Constructor) </li>
</ol></div>
</div>
<div class="refsect2">
<a name="idp182951376"></a><h3>
<a name="idp100962896-bb"></a><code class="computeroutput">date_duration</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="identifier">duration_rep</span> <a name="idp99951696-bb"></a><span class="identifier">get_rep</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>returns days_ as it's instantiated type - used for streaming </li>
<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="idp98385808-bb"></a><span class="identifier">is_special</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">duration_rep_type</span> <a name="idp107058784-bb"></a><span class="identifier">days</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>returns days as value, not object. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="idp107028336-bb"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span> rhs<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Equality. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="idp55417152-bb"></a><span class="keyword">operator</span><span class="special">&lt;</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span> rhs<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Less. </li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span> <a name="idp70186608-bb"></a><span class="keyword">operator</span><span class="special">-=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span> rhs<span class="special">)</span><span class="special">;</span></pre>Subtract another duration <span style="color: red">&lt;ndash&gt;&lt;/ndash&gt;</span> result is signed. </li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span> <a name="idp105040032-bb"></a><span class="keyword">operator</span><span class="special">+=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span> rhs<span class="special">)</span><span class="special">;</span></pre>Add a duration <span style="color: red">&lt;ndash&gt;&lt;/ndash&gt;</span> result is signed. </li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <a name="idp96827328-bb"></a><span class="keyword">operator</span><span class="special">-</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>unary- Allows for dd = -date_duration(2); -&gt; dd == -2 </li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <span class="special">&amp;</span> <a name="idp74369712-bb"></a><span class="keyword">operator</span><span class="special">/=</span><span class="special">(</span><span class="keyword">int</span> divisor<span class="special">)</span><span class="special">;</span></pre>Division operations on a duration with an integer. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="idp110799904-bb"></a><span class="identifier">is_negative</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>return sign information </li>
</ol></div>
</div>
<div class="refsect2">
<a name="idp183019216"></a><h3>
<a name="idp44073248-bb"></a><code class="computeroutput">date_duration</code> public static functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><span class="keyword">static</span> <a class="link" href="date_duration.html" title="Class template date_duration">date_duration</a> <a name="idp44073808-bb"></a><span class="identifier">unit</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Returns the smallest duration <span style="color: red">&lt;ndash&gt;&lt;/ndash&gt;</span> used by to calculate 'end'. </li></ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<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
    <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>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="day_clock.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.date_duration_hpp"><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="duration_traits_long.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
