updated documentation

[SVN r15046]
This commit is contained in:
Jeff Garland
2002-08-22 00:11:01 +00:00
parent 65425b526f
commit b22d572c70
33 changed files with 3378 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
<!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>Example Documentation</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">
<!-- Generated by Doxygen 1.2.10 -->
<hr><h1>dates_as_strings.cpp</h1> Various parsing and output of strings.
<p>
<div class="fragment"><pre><font class="comment">/*</font>
<font class="comment">The following is a simple example that shows conversion of dates to and </font>
<font class="comment">from a std::string.</font>
<font class="comment"></font>
<font class="comment">Expected output:</font>
<font class="comment">2001-Oct-09</font>
<font class="comment">2001-10-09</font>
<font class="comment">Tuesday October 9, 2001</font>
<font class="comment">An expected exception is next: </font>
<font class="comment"> Exception: Month number is out of range 1..12</font>
<font class="comment"></font>
<font class="comment">*/</font>
<font class="preprocessor">#include "boost/gdtl/gregorian/gregorian.hpp"</font>
<font class="preprocessor">#include "boost/gdtl/date_parsing.hpp"</font>
<font class="preprocessor">#include &lt;iostream&gt;</font>
<font class="preprocessor">#include &lt;string&gt;</font>
<font class="keywordtype">int</font>
main()<font class="keyword"> </font>
<font class="keyword"></font>{
<font class="keyword">using</font> <font class="keyword">namespace </font>gregorian;
<font class="keywordflow">try</font> {
<font class="comment">// The following date is in ISO 8601 extended format (CCYY-MM-DD)</font>
std::string s(<font class="stringliteral">"2001-10-9"</font>); <font class="comment">//2001-October-05</font>
date d(gdtl::parse_date&lt;date&gt;(s));
std::cout &lt;&lt; to_simple_string(d) &lt;&lt; std::endl;
<font class="comment">//Read ISO Standard(CCYYMMDD) and output ISO Extended</font>
std::string ud(<font class="stringliteral">"20011009"</font>); <font class="comment">//2001-Oct-09</font>
date d1(gdtl::parse_undelimited_date&lt;date&gt;(ud));
std::cout &lt;&lt; <a name="a1"></a>to_iso_extended_string(d1) &lt;&lt; std::endl;
<font class="comment">//Output the parts of the date - Tuesday October 9, 2001</font>
date::ymd_type ymd = d1.year_month_day();
greg_weekday wd = d1.day_of_week();
std::cout &lt;&lt; wd.as_long_string() &lt;&lt; <font class="stringliteral">" "</font>
&lt;&lt; ymd.month.as_long_string() &lt;&lt; <font class="stringliteral">" "</font>
&lt;&lt; ymd.day &lt;&lt; <font class="stringliteral">", "</font> &lt;&lt; ymd.year
&lt;&lt; std::endl;
<font class="comment">//Let's send in month 25 by accident and create an exception</font>
std::string bad_date(<font class="stringliteral">"20012509"</font>); <font class="comment">//2001-??-09</font>
std::cout &lt;&lt; <font class="stringliteral">"An expected exception is next: "</font> &lt;&lt; std::endl;
date wont_construct(gdtl::parse_undelimited_date&lt;date&gt;(bad_date));
<font class="comment">//use wont_construct so compiler doesn't complain, but you wont get here!</font>
std::cout &lt;&lt; <font class="stringliteral">"oh oh, you should reach this line: "</font>
&lt;&lt; <a name="a2"></a><a class="code" href="group__time__format.html#a4">to_iso_string</a>(wont_construct) &lt;&lt; std::endl;
}
<font class="keywordflow">catch</font>(std::exception&amp; e) {
std::cout &lt;&lt; <font class="stringliteral">" Exception: "</font> &lt;&lt; e.what() &lt;&lt; std::endl;
}
<font class="keywordflow">return</font> 0;
}
</pre></div><hr><address><small>
Generated Wed Mar 13 13:38:03 2002 by <a href="http://www.doxygen.org">Doxygen</a> for <a href="http://www.crystalclearsoftware.com">CrystalClear Software</a>&nbsp;&copy 2000-2002</small></address>
</body>
</html>