1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Class template partial_date</title> 6<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp" title="Header <boost/date_time/date_generators.hpp>"> 10<link rel="prev" href="nth_kday_of_month.html" title="Class template nth_kday_of_month"> 11<link rel="next" href="year_based_generator.html" title="Class template year_based_generator"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> 16<td align="center"><a href="../../../../index.html">Home</a></td> 17<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="nth_kday_of_month.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.date_generators_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="year_based_generator.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="refentry"> 27<a name="boost.date_time.partial_date"></a><div class="titlepage"></div> 28<div class="refnamediv"> 29<h2><span class="refentrytitle">Class template partial_date</span></h2> 30<p>boost::date_time::partial_date — Generates a date by applying the year to the given month and day. </p> 31</div> 32<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> 33<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp" title="Header <boost/date_time/date_generators.hpp>">boost/date_time/date_generators.hpp</a>> 34 35</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> date_type<span class="special">></span> 36<span class="keyword">class</span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> <span class="special">:</span> 37 <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">date_time</span><span class="special">::</span><span class="identifier">year_based_generator</span><span class="special"><</span> <span class="identifier">date_type</span> <span class="special">></span> 38<span class="special">{</span> 39<span class="keyword">public</span><span class="special">:</span> 40 <span class="comment">// types</span> 41 <span class="keyword">typedef</span> <span class="identifier">date_type</span><span class="special">::</span><span class="identifier">calendar_type</span> <a name="boost.date_time.partial_date.calendar_type"></a><span class="identifier">calendar_type</span><span class="special">;</span> 42 <span class="keyword">typedef</span> <span class="identifier">calendar_type</span><span class="special">::</span><span class="identifier">day_type</span> <a name="boost.date_time.partial_date.day_type"></a><span class="identifier">day_type</span><span class="special">;</span> 43 <span class="keyword">typedef</span> <span class="identifier">calendar_type</span><span class="special">::</span><span class="identifier">month_type</span> <a name="boost.date_time.partial_date.month_type"></a><span class="identifier">month_type</span><span class="special">;</span> 44 <span class="keyword">typedef</span> <span class="identifier">calendar_type</span><span class="special">::</span><span class="identifier">year_type</span> <a name="boost.date_time.partial_date.year_type"></a><span class="identifier">year_type</span><span class="special">;</span> 45 <span class="keyword">typedef</span> <span class="identifier">date_type</span><span class="special">::</span><span class="identifier">duration_type</span> <a name="boost.date_time.partial_date.duration_type"></a><span class="identifier">duration_type</span><span class="special">;</span> 46 <span class="keyword">typedef</span> <span class="identifier">duration_type</span><span class="special">::</span><span class="identifier">duration_rep</span> <a name="boost.date_time.partial_date.duration_rep"></a><span class="identifier">duration_rep</span><span class="special">;</span> 47 48 <span class="comment">// <a class="link" href="partial_date.html#boost.date_time.partial_dateconstruct-copy-destruct">construct/copy/destruct</a></span> 49 <a class="link" href="partial_date.html#id-1_3_14_15_3_19_2_1_6_12-bb"><span class="identifier">partial_date</span></a><span class="special">(</span><span class="identifier">day_type</span><span class="special">,</span> <span class="identifier">month_type</span><span class="special">)</span><span class="special">;</span> 50 <a class="link" href="partial_date.html#id-1_3_14_15_3_19_2_1_6_13-bb"><span class="identifier">partial_date</span></a><span class="special">(</span><span class="identifier">duration_rep</span><span class="special">)</span><span class="special">;</span> 51 52 <span class="comment">// <a class="link" href="partial_date.html#id-1_3_14_15_3_19_2_1_6_11-bb">public member functions</a></span> 53 <span class="keyword">virtual</span> <span class="identifier">date_type</span> <a class="link" href="partial_date.html#id-1_3_14_15_3_19_2_1_6_11_1-bb"><span class="identifier">get_date</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 54 <span class="identifier">date_type</span> <a class="link" href="partial_date.html#id-1_3_14_15_3_19_2_1_6_11_2-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 55 <span class="keyword">bool</span> <a class="link" href="partial_date.html#id-1_3_14_15_3_19_2_1_6_11_3-bb"><span class="keyword">operator</span><span class="special">==</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 56 <span class="keyword">bool</span> <a class="link" href="partial_date.html#id-1_3_14_15_3_19_2_1_6_11_4-bb"><span class="keyword">operator</span><span class="special"><</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> <span class="special">&</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 57 <span class="identifier">month_type</span> <a class="link" href="partial_date.html#id-1_3_14_15_3_19_2_1_6_11_5-bb"><span class="identifier">month</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 58 <span class="identifier">day_type</span> <a class="link" href="partial_date.html#id-1_3_14_15_3_19_2_1_6_11_6-bb"><span class="identifier">day</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 59 <span class="keyword">virtual</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a class="link" href="partial_date.html#id-1_3_14_15_3_19_2_1_6_11_7-bb"><span class="identifier">to_string</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 60<span class="special">}</span><span class="special">;</span></pre></div> 61<div class="refsect1"> 62<a name="id-1.3.14.15.3.19.9.4"></a><h2>Description</h2> 63<p>Example usage: </p> 64<pre class="programlisting"><span class="identifier">partial_date</span> <span class="identifier">pd</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">Jan</span><span class="special">)</span><span class="special">;</span> 65<span class="identifier">partial_date</span> <span class="identifier">pd2</span><span class="special">(</span><span class="number">70</span><span class="special">)</span><span class="special">;</span> 66<span class="identifier">date</span> <span class="identifier">d</span> <span class="special">=</span> <span class="identifier">pd</span><span class="special">.</span><span class="identifier">get_date</span><span class="special">(</span><span class="number">2002</span><span class="special">)</span><span class="special">;</span> <span class="comment">//2002-Jan-01</span> 67<span class="identifier">date</span> <span class="identifier">d2</span> <span class="special">=</span> <span class="identifier">pd2</span><span class="special">.</span><span class="identifier">get_date</span><span class="special">(</span><span class="number">2002</span><span class="special">)</span><span class="special">;</span> <span class="comment">//2002-Mar-10</span> 68</pre> 69<p> </p> 70<div class="refsect2"> 71<a name="id-1.3.14.15.3.19.9.4.3"></a><h3> 72<a name="boost.date_time.partial_dateconstruct-copy-destruct"></a><code class="computeroutput">partial_date</code> 73 public 74 construct/copy/destruct</h3> 75<div class="orderedlist"><ol class="orderedlist" type="1"> 76<li class="listitem"><pre class="literallayout"><a name="id-1_3_14_15_3_19_2_1_6_12-bb"></a><span class="identifier">partial_date</span><span class="special">(</span><span class="identifier">day_type</span> d<span class="special">,</span> <span class="identifier">month_type</span> m<span class="special">)</span><span class="special">;</span></pre></li> 77<li class="listitem"> 78<pre class="literallayout"><a name="id-1_3_14_15_3_19_2_1_6_13-bb"></a><span class="identifier">partial_date</span><span class="special">(</span><span class="identifier">duration_rep</span> days<span class="special">)</span><span class="special">;</span></pre>Partial date created from number of days into year. Range 1-366. <p>Allowable values range from 1 to 366. 1=Jan1, 366=Dec31. If argument exceeds range, <code class="computeroutput"><a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a></code> 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> 79</li> 80</ol></div> 81</div> 82<div class="refsect2"> 83<a name="id-1.3.14.15.3.19.9.4.4"></a><h3> 84<a name="id-1_3_14_15_3_19_2_1_6_11-bb"></a><code class="computeroutput">partial_date</code> public member functions</h3> 85<div class="orderedlist"><ol class="orderedlist" type="1"> 86<li class="listitem"> 87<pre class="literallayout"><span class="keyword">virtual</span> <span class="identifier">date_type</span> <a name="id-1_3_14_15_3_19_2_1_6_11_1-bb"></a><span class="identifier">get_date</span><span class="special">(</span><span class="identifier">year_type</span> y<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Return a concrete date when provided with a year specific year. <p>Will throw an 'invalid_argument' exception if a <code class="computeroutput"><a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a></code> object, instantiated with Feb-29, has get_date called with a non-leap year. Example: </p> 88<pre class="programlisting"><span class="identifier">partial_date</span> <span class="identifier">pd</span><span class="special">(</span><span class="number">29</span><span class="special">,</span> <span class="identifier">Feb</span><span class="special">)</span><span class="special">;</span> 89<span class="identifier">pd</span><span class="special">.</span><span class="identifier">get_date</span><span class="special">(</span><span class="number">2003</span><span class="special">)</span><span class="special">;</span> <span class="comment">// throws invalid_argument exception</span> 90<span class="identifier">pg</span><span class="special">.</span><span class="identifier">get_date</span><span class="special">(</span><span class="number">2000</span><span class="special">)</span><span class="special">;</span> <span class="comment">// returns 2000-2-29</span> 91</pre> 92<p> </p> 93</li> 94<li class="listitem"><pre class="literallayout"><span class="identifier">date_type</span> <a name="id-1_3_14_15_3_19_2_1_6_11_2-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="identifier">year_type</span> y<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li> 95<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="id-1_3_14_15_3_19_2_1_6_11_3-bb"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li> 96<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="id-1_3_14_15_3_19_2_1_6_11_4-bb"></a><span class="keyword">operator</span><span class="special"><</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> <span class="special">&</span> rhs<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li> 97<li class="listitem"><pre class="literallayout"><span class="identifier">month_type</span> <a name="id-1_3_14_15_3_19_2_1_6_11_5-bb"></a><span class="identifier">month</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li> 98<li class="listitem"><pre class="literallayout"><span class="identifier">day_type</span> <a name="id-1_3_14_15_3_19_2_1_6_11_6-bb"></a><span class="identifier">day</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li> 99<li class="listitem"> 100<pre class="literallayout"><span class="keyword">virtual</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a name="id-1_3_14_15_3_19_2_1_6_11_7-bb"></a><span class="identifier">to_string</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns string suitable for use in POSIX time zone string. <p>Returns string formatted with up to 3 digits: Jan-01 == "0" Feb-29 == "58" Dec-31 == "365" </p> 101</li> 102</ol></div> 103</div> 104</div> 105</div> 106<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 107<td align="left"></td> 108<td align="right"><div class="copyright-footer">Copyright © 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file 109 <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> 110</div></td> 111</tr></table> 112<hr> 113<div class="spirit-nav"> 114<a accesskey="p" href="nth_kday_of_month.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.date_generators_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="year_based_generator.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 115</div> 116</body> 117</html> 118