summaryrefslogtreecommitdiff
path: root/doc/html/boost/date_time/date.html
blob: 26872b6cd08c174a548cb007d213bd04f48adf0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Class template date</title>
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="../../index.html" title="The Boost C++ Libraries">
<link rel="up" href="../../date_time/doxy.html#id2499320" title="Header &lt;boost/date_time/date.hpp&gt;">
<link rel="prev" href="../../simple_exception_policy.html" title="Class template simple_exception_policy">
<link rel="next" href="../../day_clock.html" title="Class template day_clock">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%">
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.htm">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="../../../../people/people.htm">People</a></td>
<td align="center"><a href="../../../../more/faq.htm">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../simple_exception_policy.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#id2499320"><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="../../day_clock.html"><img src="../../images/next.png" alt="Next"></a>
</div>
<div class="refentry" lang="en">
<a name="boost.date_time.date"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template date</span></h2>
<p>boost::date_time::date &#8212; Representation of timepoint at the one day 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="bold"><strong>template</strong></span>&lt;<span class="bold"><strong>typename</strong></span> T, <span class="bold"><strong>typename</strong></span> calendar, <span class="bold"><strong>typename</strong></span> duration_type_&gt; 
<span class="bold"><strong>class</strong></span> date {
<span class="bold"><strong>public</strong></span>:
  <span class="emphasis"><em>// types</em></span>
  <span class="bold"><strong>typedef</strong></span> T                          date_type;       
  <span class="bold"><strong>typedef</strong></span> calendar                   calendar_type;   
  <span class="bold"><strong>typedef</strong></span> calendar::date_traits_type traits_type;     
  <span class="bold"><strong>typedef</strong></span> duration_type_             duration_type;   
  <span class="bold"><strong>typedef</strong></span> calendar::year_type        year_type;       
  <span class="bold"><strong>typedef</strong></span> calendar::month_type       month_type;      
  <span class="bold"><strong>typedef</strong></span> calendar::day_type         day_type;        
  <span class="bold"><strong>typedef</strong></span> calendar::ymd_type         ymd_type;        
  <span class="bold"><strong>typedef</strong></span> calendar::date_rep_type    date_rep_type;   
  <span class="bold"><strong>typedef</strong></span> calendar::date_int_type    date_int_type;   
  <span class="bold"><strong>typedef</strong></span> calendar::day_of_week_type day_of_week_type;

  <span class="emphasis"><em>// <a href="date.html#boost.date_time.dateconstruct-copy-destruct">construct/copy/destruct</a></em></span>
  <a href="date.html#id2424492-bb">date</a>(year_type, month_type, day_type);
  <a href="date.html#id2495630-bb">date</a>(<span class="bold"><strong>const</strong></span> ymd_type &amp;);
  <a href="date.html#id2410846-bb">date</a>(date_int_type);
  <a href="date.html#id2467942-bb">date</a>(date_rep_type);

  <span class="emphasis"><em>// <a href="date.html#id2525222-bb">public member functions</a></em></span>
  <span class="type">year_type</span> <a href="date.html#id2429338-bb">year</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">month_type</span> <a href="date.html#id2484410-bb">month</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">day_type</span> <a href="date.html#id2463590-bb">day</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">day_of_week_type</span> <a href="date.html#id2512874-bb">day_of_week</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">ymd_type</span> <a href="date.html#id2528573-bb">year_month_day</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="date.html#id2427916-bb"><span class="bold"><strong>operator</strong></span>&lt;</a>(<span class="bold"><strong>const</strong></span> date_type &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="date.html#id2441023-bb"><span class="bold"><strong>operator</strong></span>==</a>(<span class="bold"><strong>const</strong></span> date_type &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="date.html#id2395505-bb">is_special</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="date.html#id2516636-bb">is_not_a_date</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="date.html#id2393647-bb">is_infinity</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="date.html#id2502505-bb">is_pos_infinity</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="date.html#id2464297-bb">is_neg_infinity</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">special_values</span> <a href="date.html#id2398434-bb">as_special</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">duration_type</span> <a href="date.html#id2512442-bb"><span class="bold"><strong>operator</strong></span>-</a>(<span class="bold"><strong>const</strong></span> date_type &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type">date_type</span> <a href="date.html#id2528465-bb"><span class="bold"><strong>operator</strong></span>-</a>(<span class="bold"><strong>const</strong></span> duration_type &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type">date_type</span> <a href="date.html#id2495729-bb"><span class="bold"><strong>operator</strong></span>-=</a>(<span class="bold"><strong>const</strong></span> duration_type &amp;) ;
  <span class="type">date_rep_type</span> <a href="date.html#id2397878-bb">day_count</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">date_type</span> <a href="date.html#id2481050-bb"><span class="bold"><strong>operator</strong></span>+</a>(<span class="bold"><strong>const</strong></span> duration_type &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type">date_type</span> <a href="date.html#id2498360-bb"><span class="bold"><strong>operator</strong></span>+=</a>(<span class="bold"><strong>const</strong></span> duration_type &amp;) ;

  <span class="emphasis"><em>// <a href="date.html#id2410842-bb">protected member functions</a></em></span>
};</pre></div>
<div class="refsect1" lang="en">
<a name="id2608453"></a><h2>Description</h2>
<p>The date template represents an interface shell for a date class that is based on a year-month-day system such as the gregorian or iso systems. It provides basic operations to enable calculation and comparisons.</p>
<p><span class="bold"><strong>Theory</strong></span></p>
<p>This date representation fundamentally departs from the C tm struct approach. The goal for this type is to provide efficient date operations (add, subtract) and storage (minimize space to represent) in a concrete class. Thus, the date uses a count internally to represent a particular date. The calendar parameter defines the policies for converting the the year-month-day and internal counted form here. Applications that need to perform heavy formatting of the same date repeatedly will perform better by using the year-month-day representation.</p>
<p>Internally the date uses a day number to represent the date. This is a monotonic time representation. This representation allows for fast comparison as well as simplifying the creation of writing numeric operations. Essentially, the internal day number is like adjusted julian day. The adjustment is determined by the Epoch date which is represented as day 1 of the calendar. Day 0 is reserved for negative infinity so that any actual date is automatically greater than negative infinity. When a date is constructed from a date or formatted for output, the appropriate conversions are applied to create the year, month, day representations. </p>
<div class="refsect2" lang="en">
<a name="id2608492"></a><h3>
<a name="boost.date_time.dateconstruct-copy-destruct"></a><code class="computeroutput">date</code> construct/copy/destruct</h3>
<div class="orderedlist"><ol type="1">
<li><pre class="literallayout"><a name="id2424492-bb"></a>date(year_type y, month_type m, day_type d);</pre></li>
<li><pre class="literallayout"><a name="id2495630-bb"></a>date(<span class="bold"><strong>const</strong></span> ymd_type &amp; ymd);</pre></li>
<li>
<pre class="literallayout"><a name="id2410846-bb"></a>date(date_int_type days);</pre>
<p>This is a private constructor which allows for the creation of new dates. It is not exposed to users since that would require class users to understand the inner workings of the date class. </p>
</li>
<li><pre class="literallayout"><a name="id2467942-bb"></a>date(date_rep_type days);</pre></li>
</ol></div>
</div>
<div class="refsect2" lang="en">
<a name="id2608582"></a><h3>
<a name="id2525222-bb"></a><code class="computeroutput">date</code> public member functions</h3>
<div class="orderedlist"><ol type="1">
<li><pre class="literallayout"><span class="type">year_type</span> <a name="id2429338-bb"></a>year() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type">month_type</span> <a name="id2484410-bb"></a>month() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type">day_type</span> <a name="id2463590-bb"></a>day() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type">day_of_week_type</span> <a name="id2512874-bb"></a>day_of_week() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type">ymd_type</span> <a name="id2528573-bb"></a>year_month_day() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2427916-bb"></a><span class="bold"><strong>operator</strong></span>&lt;(<span class="bold"><strong>const</strong></span> date_type &amp; rhs) <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2441023-bb"></a><span class="bold"><strong>operator</strong></span>==(<span class="bold"><strong>const</strong></span> date_type &amp; rhs) <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2395505-bb"></a>is_special() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2516636-bb"></a>is_not_a_date() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2393647-bb"></a>is_infinity() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2502505-bb"></a>is_pos_infinity() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2464297-bb"></a>is_neg_infinity() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type">special_values</span> <a name="id2398434-bb"></a>as_special() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type">duration_type</span> <a name="id2512442-bb"></a><span class="bold"><strong>operator</strong></span>-(<span class="bold"><strong>const</strong></span> date_type &amp; d) <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type">date_type</span> <a name="id2528465-bb"></a><span class="bold"><strong>operator</strong></span>-(<span class="bold"><strong>const</strong></span> duration_type &amp; dd) <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type">date_type</span> <a name="id2495729-bb"></a><span class="bold"><strong>operator</strong></span>-=(<span class="bold"><strong>const</strong></span> duration_type &amp; dd) ;</pre></li>
<li><pre class="literallayout"><span class="type">date_rep_type</span> <a name="id2397878-bb"></a>day_count() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type">date_type</span> <a name="id2481050-bb"></a><span class="bold"><strong>operator</strong></span>+(<span class="bold"><strong>const</strong></span> duration_type &amp; dd) <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type">date_type</span> <a name="id2498360-bb"></a><span class="bold"><strong>operator</strong></span>+=(<span class="bold"><strong>const</strong></span> duration_type &amp; dd) ;</pre></li>
</ol></div>
</div>
<div class="refsect2" lang="en">
<a name="id2609130"></a><h3>
<a name="id2410842-bb"></a><code class="computeroutput">date</code> protected member functions</h3>
<div class="orderedlist"><ol type="1"></ol></div>
</div>
</div>
</div>
<table width="100%"><tr>
<td align="left"></td>
<td align="right"><small>Copyright © 2001-2005 CrystalClear Software, Inc</small></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../simple_exception_policy.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#id2499320"><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="../../day_clock.html"><img src="../../images/next.png" alt="Next"></a>
</div>
</body>
</html>