Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/doc/html/partial_date.html @ 25

Last change on this file since 25 was 12, checked in by landauf, 17 years ago

added boost

File size: 8.8 KB
Line 
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4<title>Class template partial_date</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#id2508942" title="Header &lt;boost/date_time/date_generators.hpp&gt;">
9<link rel="prev" href="year_based_generator.html" title="Class template year_based_generator">
10<link rel="next" href="nth_kday_of_month.html" title="Class template nth_kday_of_month">
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="year_based_generator.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="date_time/doxy.html#id2508942"><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="nth_kday_of_month.html"><img src="images/next.png" alt="Next"></a>
24</div>
25<div class="refentry" lang="en">
26<a name="partial_date"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Class template partial_date</span></h2>
29<p>boost::date_time::partial_date &#8212; Generates a date by applying the year to the given month and day. </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>&lt;<span class="bold"><strong>typename</strong></span> date_type&gt; 
33<span class="bold"><strong>class</strong></span> partial_date
34  :  : <span class="bold"><strong>public</strong></span> boost::date_time::year_based_generator&lt; date_type &gt;
35{
36<span class="bold"><strong>public</strong></span>:
37  <span class="emphasis"><em>// types</em></span>
38  <span class="bold"><strong>typedef</strong></span> date_type::calendar_type    calendar_type;
39  <span class="bold"><strong>typedef</strong></span> calendar_type::day_type     day_type;     
40  <span class="bold"><strong>typedef</strong></span> calendar_type::month_type   month_type;   
41  <span class="bold"><strong>typedef</strong></span> calendar_type::year_type    year_type;    
42  <span class="bold"><strong>typedef</strong></span> date_type::duration_type    duration_type;
43  <span class="bold"><strong>typedef</strong></span> duration_type::duration_rep duration_rep; 
44
45  <span class="emphasis"><em>// <a href="partial_date.html#partial_dateconstruct-copy-destruct">construct/copy/destruct</a></em></span>
46  <a href="partial_date.html#id2464976-bb">partial_date</a>(day_type, month_type);
47  <a href="partial_date.html#id2456480-bb">partial_date</a>(duration_rep);
48
49  <span class="emphasis"><em>// <a href="partial_date.html#id2472423-bb">public member functions</a></em></span>
50  <span class="type">date_type</span> <a href="partial_date.html#id2472427-bb">get_date</a>(year_type) <span class="bold"><strong>const</strong></span>;
51  <span class="type">date_type</span> <a href="partial_date.html#id2489992-bb"><span class="bold"><strong>operator</strong></span>()</a>(year_type) <span class="bold"><strong>const</strong></span>;
52  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="partial_date.html#id2417278-bb"><span class="bold"><strong>operator</strong></span>==</a>(<span class="bold"><strong>const</strong></span> <a href="partial_date.html" title="Class template partial_date">partial_date</a> &amp;) <span class="bold"><strong>const</strong></span>;
53  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="partial_date.html#id2498407-bb"><span class="bold"><strong>operator</strong></span>&lt;</a>(<span class="bold"><strong>const</strong></span> <a href="partial_date.html" title="Class template partial_date">partial_date</a> &amp;) <span class="bold"><strong>const</strong></span>;
54  <span class="type">month_type</span> <a href="partial_date.html#id2478664-bb">month</a>() <span class="bold"><strong>const</strong></span>;
55  <span class="type">day_type</span> <a href="partial_date.html#id2507935-bb">day</a>() <span class="bold"><strong>const</strong></span>;
56  <span class="type"><span class="bold"><strong>virtual</strong></span> std::string</span> <a href="partial_date.html#id2507947-bb">to_string</a>() <span class="bold"><strong>const</strong></span>;
57};</pre></div>
58<div class="refsect1" lang="en">
59<a name="id2624612"></a><h2>Description</h2>
60<p>Example usage: </p>
61<pre class="programlisting">    partial_date pd(1, Jan);
62    partial_date pd2(70);
63    date d = pd.get_date(2002); //2002-Jan-01
64    date d2 = pd2.get_date(2002); //2002-Mar-10
65</pre>
66<div class="refsect2" lang="en">
67<a name="id2624625"></a><h3>
68<a name="partial_dateconstruct-copy-destruct"></a><code class="computeroutput">partial_date</code> construct/copy/destruct</h3>
69<div class="orderedlist"><ol type="1">
70<li><pre class="literallayout"><a name="id2464976-bb"></a>partial_date(day_type d, month_type m);</pre></li>
71<li>
72<pre class="literallayout"><a name="id2456480-bb"></a>partial_date(duration_rep days);</pre>
73<p>Allowable values range from 1 to 366. 1=Jan1, 366=Dec31. If argument exceeds range, partial_date will be created with closest in-range value. 60 will always be Feb29, if get_date() is called with a non-leap year an exception will be thrown </p>
74</li>
75</ol></div>
76</div>
77<div class="refsect2" lang="en">
78<a name="id2624678"></a><h3>
79<a name="id2472423-bb"></a><code class="computeroutput">partial_date</code> public member functions</h3>
80<div class="orderedlist"><ol type="1">
81<li>
82<pre class="literallayout"><span class="type">date_type</span> <a name="id2472427-bb"></a>get_date(year_type y) <span class="bold"><strong>const</strong></span>;</pre>
83<p>Will throw an 'invalid_argument' exception if a partial_date object, instantiated with Feb-29, has get_date called with a non-leap year. Example: </p>
84<pre class="programlisting"> partial_date pd(29, Feb);
85 pd.get_date(2003); // throws invalid_argument exception
86 pg.get_date(2000); // returns 2000-2-29
87</pre>
88</li>
89<li><pre class="literallayout"><span class="type">date_type</span> <a name="id2489992-bb"></a><span class="bold"><strong>operator</strong></span>()(year_type y) <span class="bold"><strong>const</strong></span>;</pre></li>
90<li><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2417278-bb"></a><span class="bold"><strong>operator</strong></span>==(<span class="bold"><strong>const</strong></span> <a href="partial_date.html" title="Class template partial_date">partial_date</a> &amp; rhs) <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="id2498407-bb"></a><span class="bold"><strong>operator</strong></span>&lt;(<span class="bold"><strong>const</strong></span> <a href="partial_date.html" title="Class template partial_date">partial_date</a> &amp; rhs) <span class="bold"><strong>const</strong></span>;</pre></li>
92<li><pre class="literallayout"><span class="type">month_type</span> <a name="id2478664-bb"></a>month() <span class="bold"><strong>const</strong></span>;</pre></li>
93<li><pre class="literallayout"><span class="type">day_type</span> <a name="id2507935-bb"></a>day() <span class="bold"><strong>const</strong></span>;</pre></li>
94<li>
95<pre class="literallayout"><span class="type"><span class="bold"><strong>virtual</strong></span> std::string</span> <a name="id2507947-bb"></a>to_string() <span class="bold"><strong>const</strong></span>;</pre>
96<p>Returns string formatted with up to 3 digits: Jan-01 == "0" Feb-29 == "58" Dec-31 == "365" </p>
97</li>
98</ol></div>
99</div>
100</div>
101</div>
102<table width="100%"><tr>
103<td align="left"></td>
104<td align="right"><small>Copyright © 2001-2005 CrystalClear Software, Inc</small></td>
105</tr></table>
106<hr>
107<div class="spirit-nav">
108<a accesskey="p" href="year_based_generator.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="date_time/doxy.html#id2508942"><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="nth_kday_of_month.html"><img src="images/next.png" alt="Next"></a>
109</div>
110</body>
111</html>
Note: See TracBrowser for help on using the repository browser.