mirror of
https://github.com/boostorg/date_time.git
synced 2026-01-28 19:12:17 +00:00
128 lines
4.0 KiB
HTML
128 lines
4.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
|
<title>gregorian::date_duration Documentation</title>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
|
</head>
|
|
|
|
<body>
|
|
<a href="../../../index.htm">
|
|
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
|
</a>
|
|
|
|
<h1>gregorian::date_duration</h1>
|
|
<hr>
|
|
<p>
|
|
<p>
|
|
<a href="index.html">Overall Index</a> --
|
|
<a href="gregorian.html">Gregorian Index</a> --
|
|
<a href="posix_time.html">Posix Time Index</a>
|
|
<p>
|
|
<font class="bold">Date Documentation</font>
|
|
<p>
|
|
<a href="class_date_duration.html#header">Header</a> --
|
|
<a href="class_date_duration.html#construct">Construction</a> --
|
|
<a href="class_date_duration.html#accessors">Accessors</a> --
|
|
<a href="class_date_duration.html#operators">Operators</a>
|
|
<p>
|
|
<h2><a name="intro">Introduction</a></h2>
|
|
|
|
<p>
|
|
The class boost::gregorian::date_duration is a simple day count used for arithmetic
|
|
with <a href="class_date.html">gregorian::date</a>. A duration can be either
|
|
positive or negative. In addition, date_durations can take on special values such
|
|
as not_a_date_time. More information on how these special values impact calculation
|
|
can be found in <a href="Calculations.html">Calculations</a>.
|
|
<p>
|
|
|
|
<p>
|
|
<h2><a name="header">Header</a></h2>
|
|
<pre>
|
|
#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
|
|
or
|
|
#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
|
|
</pre>
|
|
<p>
|
|
|
|
<h2><a name="construct">Construction</a></h2>
|
|
|
|
|
|
<p>
|
|
<table border=1 cellspacing=3 cellpadding=3>
|
|
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
|
<tr><td>date_duration(long)</td>
|
|
<td>Create a duration count.</td>
|
|
<td>date_duration dd(3); //3 days</td></tr>
|
|
<tr><td>date_duration(const date_duration& dd)</td>
|
|
<td>Copy constructor.</td>
|
|
<td></td></tr>
|
|
<tr><td>date_duration(special_values)</td>
|
|
<td>Create a duration with a special value such as neg_infin,
|
|
pos_infin or not_a_date_time</td>
|
|
<td>date_duration dd(note_a_date_time); //invalid value</td></tr>
|
|
</table>
|
|
|
|
<p>
|
|
|
|
<h2><a name="accessors">Accessors</a></h2>
|
|
|
|
|
|
<p>
|
|
<table border=1 cellspacing=3 cellpadding=3>
|
|
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
|
<tr><td>long <font class="func">days</font>() const</td>
|
|
<td>Get the day count.</td>
|
|
<td>date_duration dd(3); dd.days() --> 3</td></tr>
|
|
<tr><td>bool <font class="func">is_negative</font>() const</td>
|
|
<td>True if number of days is less than zero..</td>
|
|
<td>date_duration dd(-1); dd.is_negative() --> true</td></tr>
|
|
<tr><td>static date_duration <font class="func">unit</font>()</td>
|
|
<td>Return smallest possible unit of duration type.</td>
|
|
<td>date_duration::unit() --> date_duration(1)</td></tr>
|
|
|
|
</table>
|
|
|
|
<p>
|
|
|
|
<h2><a name="operators">Operators</a></h2>
|
|
|
|
|
|
<p>
|
|
<table border=1 cellspacing=3 cellpadding=3>
|
|
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
|
<tr><td>operator==, operator!=,<br>
|
|
operator>, operator< <br>
|
|
operator>=, operator<=</td>
|
|
<td>A full complement of comparison operators</td>
|
|
<td>dd1 == dd2, etc</td></tr>
|
|
<tr><td>date_duration operator+(date_duration) const</td>
|
|
<td>Add date durations.</td>
|
|
<td>date_duration dd1(3);
|
|
<br>date_duration dd2(5);
|
|
<br>date_duration dd3 = dd1 + dd2;</td></tr>
|
|
<tr><td>date_duration operator-(date_duration) const</td>
|
|
<td>Subtract durations.</td>
|
|
<td>date_duration dd1(3);
|
|
<br>date_duration dd2(5);
|
|
<br>date_duration dd3 = dd1 - dd2;</td></tr>
|
|
<tr><td>date_duration operator-() const</td>
|
|
<td>Invert sign</td>
|
|
<td>date_duration dd1(3);
|
|
<br>-dd1; // dd1 == -3 days
|
|
</td></tr>
|
|
|
|
</table>
|
|
|
|
<p>
|
|
|
|
|
|
<hr>
|
|
<address><small>
|
|
<!-- hhmts start -->
|
|
Last modified: Sun Jan 18 15:15:35 MST 2004
|
|
<!-- hhmts end -->
|
|
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
|
</small></address>
|
|
</body>
|
|
</html>
|
|
|