<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Class template partial_date</title> <link rel="stylesheet" href="../../boostbook.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> <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_generators_hpp" title="Header <boost/date_time/date_generators.hpp>"> <link rel="prev" href="year_based_generator.html" title="Class template year_based_generator"> <link rel="next" href="nth_kday_of_month.html" title="Class template nth_kday_of_month"> </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="year_based_generator.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="nth_kday_of_month.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a> </div> <div class="refentry" title="Class template partial_date"> <a name="boost.date_time.partial_date"></a><div class="titlepage"></div> <div class="refnamediv"> <h2><span class="refentrytitle">Class template partial_date</span></h2> <p>boost::date_time::partial_date — Generates a date by applying the year to the given month and day. </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="emphasis"><em>// 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>> </em></span><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> date_type> <span class="bold"><strong>class</strong></span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> : <span class="bold"><strong>public</strong></span> boost::date_time::year_based_generator< date_type > { <span class="bold"><strong>public</strong></span>: <span class="emphasis"><em>// types</em></span> <span class="bold"><strong>typedef</strong></span> date_type::calendar_type <a name="boost.date_time.partial_date.calendar_type"></a>calendar_type; <span class="bold"><strong>typedef</strong></span> calendar_type::day_type <a name="boost.date_time.partial_date.day_type"></a>day_type; <span class="bold"><strong>typedef</strong></span> calendar_type::month_type <a name="boost.date_time.partial_date.month_type"></a>month_type; <span class="bold"><strong>typedef</strong></span> calendar_type::year_type <a name="boost.date_time.partial_date.year_type"></a>year_type; <span class="bold"><strong>typedef</strong></span> date_type::duration_type <a name="boost.date_time.partial_date.duration_type"></a>duration_type; <span class="bold"><strong>typedef</strong></span> duration_type::duration_rep <a name="boost.date_time.partial_date.duration_rep"></a>duration_rep; <span class="emphasis"><em>// <a class="link" href="partial_date.html#boost.date_time.partial_dateconstruct-copy-destruct">construct/copy/destruct</a></em></span> <a class="link" href="partial_date.html#id321161-bb">partial_date</a>(day_type, month_type); <a class="link" href="partial_date.html#id321173-bb">partial_date</a>(duration_rep); <span class="emphasis"><em>// <a class="link" href="partial_date.html#id377351-bb">public member functions</a></em></span> <span class="type">date_type</span> <a class="link" href="partial_date.html#id377354-bb">get_date</a>(year_type) <span class="bold"><strong>const</strong></span>; <span class="type">date_type</span> <a class="link" href="partial_date.html#id362086-bb"><span class="bold"><strong>operator</strong></span>()</a>(year_type) <span class="bold"><strong>const</strong></span>; <span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="partial_date.html#id336888-bb"><span class="bold"><strong>operator</strong></span>==</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> &) <span class="bold"><strong>const</strong></span>; <span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="partial_date.html#id336905-bb"><span class="bold"><strong>operator</strong></span><</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> &) <span class="bold"><strong>const</strong></span>; <span class="type">month_type</span> <a class="link" href="partial_date.html#id336922-bb">month</a>() <span class="bold"><strong>const</strong></span>; <span class="type">day_type</span> <a class="link" href="partial_date.html#id336930-bb">day</a>() <span class="bold"><strong>const</strong></span>; <span class="type">std::string</span> <a class="link" href="partial_date.html#id409334-bb">to_string</a>() <span class="bold"><strong>const</strong></span>; };</pre></div> <div class="refsect1" title="Description"> <a name="id785989"></a><h2>Description</h2> <p>Example usage: </p> <pre class="programlisting"> partial_date pd(1, Jan); partial_date pd2(70); date d = pd.get_date(2002); //2002-Jan-01 date d2 = pd2.get_date(2002); //2002-Mar-10 </pre> <p> </p> <div class="refsect2" title="partial_date public construct/copy/destruct"> <a name="id786003"></a><h3> <a name="boost.date_time.partial_dateconstruct-copy-destruct"></a><code class="computeroutput">partial_date</code> public construct/copy/destruct</h3> <div class="orderedlist"><ol class="orderedlist" type="1"> <li class="listitem"><pre class="literallayout"><a name="id321161-bb"></a>partial_date(day_type d, month_type m);</pre></li> <li class="listitem"> <pre class="literallayout"><a name="id321173-bb"></a>partial_date(duration_rep days);</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, 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> </li> </ol></div> </div> <div class="refsect2" title="partial_date public member functions"> <a name="id786060"></a><h3> <a name="id377351-bb"></a><code class="computeroutput">partial_date</code> public member functions</h3> <div class="orderedlist"><ol class="orderedlist" type="1"> <li class="listitem"> <pre class="literallayout"><span class="type">date_type</span> <a name="id377354-bb"></a>get_date(year_type y) <span class="bold"><strong>const</strong></span>;</pre>Return a concrete date when provided with a year specific year. <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> <pre class="programlisting"> partial_date pd(29, Feb); pd.get_date(2003); // throws invalid_argument exception pg.get_date(2000); // returns 2000-2-29 </pre> <p> </p> </li> <li class="listitem"><pre class="literallayout"><span class="type">date_type</span> <a name="id362086-bb"></a><span class="bold"><strong>operator</strong></span>()(year_type y) <span class="bold"><strong>const</strong></span>;</pre></li> <li class="listitem"><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id336888-bb"></a><span class="bold"><strong>operator</strong></span>==(<span class="bold"><strong>const</strong></span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> & rhs) <span class="bold"><strong>const</strong></span>;</pre></li> <li class="listitem"><pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id336905-bb"></a><span class="bold"><strong>operator</strong></span><(<span class="bold"><strong>const</strong></span> <a class="link" href="partial_date.html" title="Class template partial_date">partial_date</a> & rhs) <span class="bold"><strong>const</strong></span>;</pre></li> <li class="listitem"><pre class="literallayout"><span class="type">month_type</span> <a name="id336922-bb"></a>month() <span class="bold"><strong>const</strong></span>;</pre></li> <li class="listitem"><pre class="literallayout"><span class="type">day_type</span> <a name="id336930-bb"></a>day() <span class="bold"><strong>const</strong></span>;</pre></li> <li class="listitem"> <pre class="literallayout"><span class="type">std::string</span> <a name="id409334-bb"></a>to_string() <span class="bold"><strong>const</strong></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> </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 © 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="year_based_generator.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="nth_kday_of_month.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a> </div> </body> </html>