Imported Upstream version 1.57.0
[platform/upstream/boost.git] / doc / html / date_time / date_time_io.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Date Time Input/Output</title>
5 <link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
7 <link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
8 <link rel="up" href="../date_time.html" title="Chapter&#160;9.&#160;Boost.Date_Time">
9 <link rel="prev" href="local_time.html" title="Local Time">
10 <link rel="next" href="serialization.html" title="Serialization">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
15 <td align="center"><a href="../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <a accesskey="p" href="local_time.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../date_time.html"><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="serialization.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
27 <a name="date_time.date_time_io"></a>Date Time Input/Output</h2></div></div></div>
28 <div class="toc"><dl class="toc">
29 <dt><span class="section"><a href="date_time_io.html#date_time.format_flags">Format Flags</a></span></dt>
30 <dt><span class="section"><a href="date_time_io.html#date_time.date_facet">Date Facet</a></span></dt>
31 <dt><span class="section"><a href="date_time_io.html#date_time.date_input_facet">Date Input Facet</a></span></dt>
32 <dt><span class="section"><a href="date_time_io.html#date_time.time_facet">Time Facet</a></span></dt>
33 <dt><span class="section"><a href="date_time_io.html#date_time.time_input_facet">Time Input Facet</a></span></dt>
34 <dt><span class="section"><a href="date_time_io.html#date_time.io_objects">Date Time Formatter/Parser Objects</a></span></dt>
35 <dt><span class="section"><a href="date_time_io.html#date_time.io_tutorial">Date Time IO Tutorial</a></span></dt>
36 </dl></div>
37 <h3>
38 <a name="idp179854336"></a>Date Time IO System</h3>
39 <p>
40     <a class="link" href="date_time_io.html#streaming_exceptions">Exception Handling on Streams</a>
41   </p>
42 <p>As of version 1.33, the date_time library utilizes a new IO streaming system. This new system gives the user great control over how dates and times can be represented. The customization options can be broken down into two groups: format flags and string elements. Format flags provide flexibility in the order of the date elements as well as the type. Customizing the string elements allows the replacement of built in strings from month names, weekday names, and other strings used in the IO.</p>
43 <p>The output system is based on a date_facet (derived from std::facet), while the input system is based on a date_input_facet (also derived from std::facet). The time and local_time facets are derived from these base types. The output system utilizes three formatter objects, whereas the input system uses four parser objects. These formatter and parser objetcs are also customizable.</p>
44 <p>It is important to note, that while all the examples shown here use narrow streams, there are wide stream facets available as well (see <a class="link" href="date_time_io.html#io_objects_table">IO Objects</a> for a complete list).</p>
45 <p>It should be further noted that not all compilers are capable of using this IO system. For those compilers the IO system used in previous <code class="computeroutput">date_time</code> versions is still available. The "legacy IO" is automatically selected for these compilers, however, the legacy IO system can be manually selected by defining <code class="computeroutput">USE_DATE_TIME_PRE_1_33_FACET_IO</code>. See the <a class="link" href="details.html#date_time.buildinfo" title="Build-Compiler Information">Build-Compiler Information</a> for more information.</p>
46 <a name="streaming_exceptions"></a><h6>
47 <a name="idp179863344"></a>Exception Handling on Streams</h6>
48 <p>When an error occurs during the input streaming process, the <code class="computeroutput">std::ios_base::failbit</code> will (always) be set on the stream. It is also possible to have exceptions thrown when an error occurs. To "turn on" these exceptions, call the stream's <code class="computeroutput">exceptions</code> function with a parameter of <code class="computeroutput">std::ios_base::failbit</code>.</p>
49 <pre class="screen">// "Turning on" exceptions
50 date d(not_a_date_time);
51 std::stringstream ss;
52 ss.exceptions(std::ios_base::failbit);
53 ss.str("204-Jan-01");
54 ss &gt;&gt; d; // throws bad_year exception AND sets failbit on stream</pre>
55 <h6>
56 <a name="idp179867712"></a>A simple example of this new system:</h6>
57 <pre class="screen">//example to customize output to be "LongWeekday LongMonthname day, year"
58 //                                  "%A %b %d, %Y"
59 date d(2005,Jun,25);
60 date_facet* facet(new date_facet("%A %B %d, %Y"));
61 std::cout.imbue(std::locale(std::cout.getloc(), facet));
62 std::cout &lt;&lt; d &lt;&lt; std::endl;
63 // "Saturday June 25, 2005"</pre>
64 <div class="section">
65 <div class="titlepage"><div><div><h3 class="title">
66 <a name="date_time.format_flags"></a>Format Flags</h3></div></div></div>
67 <p>Many of the format flags this new system uses for output are those used by <code class="computeroutput">strftime(...)</code>, but not all. Some new flags have been added, and others overridden. The input system supports only specific flags, therefore, not all flags that work for output will work with input (we are currently working to correct this situation).</p>
68 <p>The following tables list the all the flags available for both date_time IO as well as strftime. Format flags marked with a single asterisk (*) have a behavior unique to date_time. Those flags marked with an exclamation point (!) are not usable for input (at this time). The flags marked with a hash sign (#) are implemented by system locale and are known to be missing on some platforms. The first table is for dates, and the second table is for times.
69   </p>
70 <p>
71     <a name="date_time_io.date_format_flags"></a>
72     Date Facet Format Flags
73     </p>
74 <div class="informaltable"><table class="table">
75 <colgroup>
76 <col>
77 <col>
78 </colgroup>
79 <thead>
80 <tr>
81 <th rowspan="2" valign="top">Format Specifier</th>
82 <th>Description</th>
83 </tr>
84 <tr><th>Example</th></tr>
85 </thead>
86 <tbody>
87 <tr>
88 <td rowspan="2" valign="top"><pre class="screen">%a</pre></td>
89 <td>Abbreviated weekday name</td>
90 </tr>
91 <tr><td><pre class="screen">"Mon" =&gt; Monday</pre></td></tr>
92 <tr>
93 <td rowspan="2" valign="top"><pre class="screen">%A</pre></td>
94 <td>Long weekday name</td>
95 </tr>
96 <tr><td><pre class="screen">"Monday"</pre></td></tr>
97 <tr>
98 <td rowspan="2" valign="top"><pre class="screen">%b</pre></td>
99 <td>Abbreviated month name</td>
100 </tr>
101 <tr><td><pre class="screen">"Feb" =&gt; February</pre></td></tr>
102 <tr>
103 <td rowspan="2" valign="top"><pre class="screen">%B</pre></td>
104 <td>Full month name</td>
105 </tr>
106 <tr><td><pre class="screen">"February"</pre></td></tr>
107 <tr>
108 <td rowspan="2" valign="top"><pre class="screen">%c !</pre></td>
109 <td>The  preferred  date  and  time  representation  for the current locale.</td>
110 </tr>
111 <tr><td><pre class="screen"></pre></td></tr>
112 <tr>
113 <td rowspan="2" valign="top"><pre class="screen">%C !#</pre></td>
114 <td>The century number (year/100) as a 2-digit integer.</td>
115 </tr>
116 <tr><td><pre class="screen"></pre></td></tr>
117 <tr>
118 <td rowspan="2" valign="top"><pre class="screen">%d</pre></td>
119 <td>Day of the month as decimal 01 to 31</td>
120 </tr>
121 <tr><td><pre class="screen"></pre></td></tr>
122 <tr>
123 <td rowspan="2" valign="top"><pre class="screen">%D !#</pre></td>
124 <td>Equivalent to %m/%d/%y</td>
125 </tr>
126 <tr><td><pre class="screen"></pre></td></tr>
127 <tr>
128 <td rowspan="2" valign="top"><pre class="screen">%e #</pre></td>
129 <td>Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space</td>
130 </tr>
131 <tr><td><pre class="screen"></pre></td></tr>
132 <tr>
133 <td rowspan="2" valign="top"><pre class="screen">%G !</pre></td>
134 <td>This has the same format and value as %y, except that if the ISO week number belongs to the previous or next year, that year is used instead.</td>
135 </tr>
136 <tr><td><pre class="screen"></pre></td></tr>
137 <tr>
138 <td rowspan="2" valign="top"><pre class="screen">%g !</pre></td>
139 <td>Like %G, but without century.</td>
140 </tr>
141 <tr><td><pre class="screen"></pre></td></tr>
142 <tr>
143 <td rowspan="2" valign="top"><pre class="screen">%h !#</pre></td>
144 <td> Equivalent to %b</td>
145 </tr>
146 <tr><td><pre class="screen"></pre></td></tr>
147 <tr>
148 <td rowspan="2" valign="top"><pre class="screen">%j</pre></td>
149 <td>Day of year as decimal from 001 to 366 for leap years, 001 - 365 for non-leap years.</td>
150 </tr>
151 <tr><td><pre class="screen">"060" =&gt; Feb-29</pre></td></tr>
152 <tr>
153 <td rowspan="2" valign="top"><pre class="screen">%m</pre></td>
154 <td>Month name as a decimal 01 to 12</td>
155 </tr>
156 <tr><td><pre class="screen">"01" =&gt; January</pre></td></tr>
157 <tr>
158 <td rowspan="2" valign="top"><pre class="screen">%u !</pre></td>
159 <td>The  day of the week as a decimal, range 1 to 7, Monday being 1.</td>
160 </tr>
161 <tr><td><pre class="screen"></pre></td></tr>
162 <tr>
163 <td rowspan="2" valign="top"><pre class="screen">%U</pre></td>
164 <td>The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. In 2005, Jan 1st falls on a Saturday, so therefore it falls within week 00 of 2005 (week 00 spans 2004-Dec-26 to 2005-Jan-01. This also happens to be week 53 of 2004).</td>
165 </tr>
166 <tr><td><pre class="screen">date d(2005, Jan, 1); // Saturday
167 // with format %U
168 ss &lt;&lt; d; // "00"
169 d += day(1); // Sunday
170 ss &lt;&lt; d; // "01" beginning of week 1</pre></td></tr>
171 <tr>
172 <td rowspan="2" valign="top"><pre class="screen">%V !#</pre></td>
173 <td>The ISO 8601:1988 week number of the current year as  a  decimal number,  range 01 to 53, where week 1 is the first week that has at least 4 days in the current year,  and  with  Monday  as  the first day of the week.</td>
174 </tr>
175 <tr><td><pre class="screen"></pre></td></tr>
176 <tr>
177 <td rowspan="2" valign="top"><pre class="screen">%w</pre></td>
178 <td>Weekday as decimal number 0 to 6</td>
179 </tr>
180 <tr><td><pre class="screen">"0" =&gt; Sunday</pre></td></tr>
181 <tr>
182 <td rowspan="2" valign="top"><pre class="screen">%W</pre></td>
183 <td>Week number 00 to 53 where Monday is first day of week 1</td>
184 </tr>
185 <tr><td><pre class="screen">date d(2005, Jan, 2); // Sunday
186 // with format %W
187 ss &lt;&lt; d; // "00"
188 d += day(1); // Monday
189 ss &lt;&lt; d; // "01" beginning of week 1</pre></td></tr>
190 <tr>
191 <td rowspan="2" valign="top"><pre class="screen">%x</pre></td>
192 <td>Implementation defined date format from the locale.</td>
193 </tr>
194 <tr><td><pre class="screen">date d(2005,Oct,31);
195 date_facet* f = new date_facet("%x");
196
197 locale loc = locale(locale("en_US"), f);
198 cout.imbue(loc);
199 cout &lt;&lt; d; // "10/31/2005"
200
201 loc = locale(locale("de_DE"), f);
202 cout.imbue(loc);
203 cout &lt;&lt; d; // "31.10.2005"</pre></td></tr>
204 <tr>
205 <td rowspan="2" valign="top"><pre class="screen">%y</pre></td>
206 <td>Two digit year</td>
207 </tr>
208 <tr><td><pre class="screen">"05" =&gt; 2005</pre></td></tr>
209 <tr>
210 <td rowspan="2" valign="top"><pre class="screen">%Y</pre></td>
211 <td>Four digit year</td>
212 </tr>
213 <tr><td><pre class="screen">"2005"</pre></td></tr>
214 <tr>
215 <td rowspan="2" valign="top"><pre class="screen">%Y-%b-%d</pre></td>
216 <td>Default date format</td>
217 </tr>
218 <tr><td><pre class="screen">"2005-Apr-01"</pre></td></tr>
219 <tr>
220 <td rowspan="2" valign="top"><pre class="screen">%Y%m%d</pre></td>
221 <td>ISO format</td>
222 </tr>
223 <tr><td><pre class="screen">"20050401"</pre></td></tr>
224 <tr>
225 <td rowspan="2" valign="top"><pre class="screen">%Y-%m-%d</pre></td>
226 <td>ISO extended format</td>
227 </tr>
228 <tr><td><pre class="screen">"2005-04-01"</pre></td></tr>
229 </tbody>
230 </table></div>
231 <p>
232
233
234     <a name="date_time_io.time_format_flags"></a>
235     Time Facet Format Flags
236     </p>
237 <div class="informaltable"><table class="table">
238 <colgroup>
239 <col>
240 <col>
241 </colgroup>
242 <thead>
243 <tr>
244 <th rowspan="2" valign="top">Format Specifier</th>
245 <th>Description</th>
246 </tr>
247 <tr><th>Example</th></tr>
248 </thead>
249 <tbody>
250 <tr>
251 <td rowspan="2" valign="top"><pre class="screen">%- *!</pre></td>
252 <td>Placeholder for the sign of a duration. Only displays when the duration is negative.</td>
253 </tr>
254 <tr><td><pre class="screen">"-13:15:16"</pre></td></tr>
255 <tr>
256 <td rowspan="2" valign="top"><pre class="screen">%+ *!</pre></td>
257 <td>Placeholder for the sign of a duration. Always displays for both positive and negative.</td>
258 </tr>
259 <tr><td><pre class="screen">"+13:15:16"</pre></td></tr>
260 <tr>
261 <td rowspan="2" valign="top"><pre class="screen">%f</pre></td>
262 <td>Fractional seconds are always used, even when their value is zero</td>
263 </tr>
264 <tr><td><pre class="screen">"13:15:16.000000"</pre></td></tr>
265 <tr>
266 <td rowspan="2" valign="top"><pre class="screen">%F *</pre></td>
267 <td>Fractional seconds are used only when their value is not zero.</td>
268 </tr>
269 <tr><td><pre class="screen">"13:15:16"
270 "05:04:03.001234"</pre></td></tr>
271 <tr>
272 <td rowspan="2" valign="top"><pre class="screen">%H</pre></td>
273 <td>The hour as a decimal number using a 24-hour clock (range 00 to 23).</td>
274 </tr>
275 <tr><td>&#160;</td></tr>
276 <tr>
277 <td rowspan="2" valign="top"><pre class="screen">%I !</pre></td>
278 <td>The hour as a decimal number using a 12-hour clock (range 01 to 12).</td>
279 </tr>
280 <tr><td>&#160;</td></tr>
281 <tr>
282 <td rowspan="2" valign="top"><pre class="screen">%k !</pre></td>
283 <td>The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank.</td>
284 </tr>
285 <tr><td>&#160;</td></tr>
286 <tr>
287 <td rowspan="2" valign="top"><pre class="screen">%l !</pre></td>
288 <td>The hour (12-hour clock) as a decimal number (range  1  to  12); single digits are preceded by a blank.</td>
289 </tr>
290 <tr><td>&#160;</td></tr>
291 <tr>
292 <td rowspan="2" valign="top"><pre class="screen">%M</pre></td>
293 <td>The minute as a decimal number (range 00 to 59).</td>
294 </tr>
295 <tr><td>&#160;</td></tr>
296 <tr>
297 <td rowspan="2" valign="top"><pre class="screen">%O</pre></td>
298 <td>The number of hours in a time duration as a decimal number (range 0 to max. representable duration); single digits are preceded by a zero.</td>
299 </tr>
300 <tr><td>&#160;</td></tr>
301 <tr>
302 <td rowspan="2" valign="top"><pre class="screen">%p !</pre></td>
303 <td>Either `AM' or `PM' according to the given time value, or the corresponding strings for the current locale.</td>
304 </tr>
305 <tr><td>&#160;</td></tr>
306 <tr>
307 <td rowspan="2" valign="top"><pre class="screen">%P !#</pre></td>
308 <td>Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale.</td>
309 </tr>
310 <tr><td>&#160;</td></tr>
311 <tr>
312 <td rowspan="2" valign="top"><pre class="screen">%r !#</pre></td>
313 <td>The time in a.m. or p.m. notation. In the POSIX locale this is equivalent to `%I:%M:%S %p'</td>
314 </tr>
315 <tr><td>&#160;</td></tr>
316 <tr>
317 <td rowspan="2" valign="top"><pre class="screen">%R !</pre></td>
318 <td>The time in 24-hour notation (%H:%M)</td>
319 </tr>
320 <tr><td>&#160;</td></tr>
321 <tr>
322 <td rowspan="2" valign="top"><pre class="screen">%s *</pre></td>
323 <td>Seconds with fractional seconds.</td>
324 </tr>
325 <tr><td><pre class="screen">"59.000000"</pre></td></tr>
326 <tr>
327 <td rowspan="2" valign="top"><pre class="screen">%S</pre></td>
328 <td>Seconds only</td>
329 </tr>
330 <tr><td><pre class="screen">"59"</pre></td></tr>
331 <tr>
332 <td rowspan="2" valign="top"><pre class="screen">%T !</pre></td>
333 <td>The time in 24-hour notation (%H:%M:%S)</td>
334 </tr>
335 <tr><td>&#160;</td></tr>
336 <tr>
337 <td rowspan="2" valign="top"><pre class="screen">%q</pre></td>
338 <td>ISO time zone (output only). This flag is ignored when using the time_facet with a ptime.</td>
339 </tr>
340 <tr><td><pre class="screen">"-0700" // Mountain Standard Time</pre></td></tr>
341 <tr>
342 <td rowspan="2" valign="top"><pre class="screen">%Q</pre></td>
343 <td>ISO extended time zone (output only). This flag is ignored when using the time_facet with a ptime.</td>
344 </tr>
345 <tr><td><pre class="screen">"-05:00" // Eastern Standard Time</pre></td></tr>
346 <tr>
347 <td rowspan="2" valign="top"><pre class="screen">%z *!</pre></td>
348 <td>Abbreviated time zone (output only). This flag is ignored when using the time_facet with a ptime.</td>
349 </tr>
350 <tr><td><pre class="screen">"MST" // Mountain Standard Time</pre></td></tr>
351 <tr>
352 <td rowspan="2" valign="top"><pre class="screen">%Z *!</pre></td>
353 <td>Full time zone name (output only). This flag is ignored when using the time_facet with a ptime.</td>
354 </tr>
355 <tr><td><pre class="screen">"EDT" // Eastern Daylight Time</pre></td></tr>
356 <tr>
357 <td rowspan="2" valign="top"><pre class="screen">%ZP *</pre></td>
358 <td>Posix time zone string (available to both input and output). This flag is ignored when using the time_facet with a ptime. For complete details on posix time zone strings, see <a class="link" href="local_time.html#date_time.local_time.posix_time_zone" title="Posix Time Zone">posix_time_zone class</a>.</td>
359 </tr>
360 <tr><td><pre class="screen">"EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00"</pre></td></tr>
361 <tr>
362 <td rowspan="2" valign="top"><pre class="screen">%x %X</pre></td>
363 <td>Implementation defined date/time format from the locale.</td>
364 </tr>
365 <tr><td><pre class="screen">date d(2005,Oct,31);
366 ptime pt(d, hours(20));
367 time_facet* f = new time_facet("%x %X");
368
369 locale loc = locale(locale("en_US"), f);
370 cout.imbue(loc);
371 cout &lt;&lt; pt; // "10/31/2005 08:00:00 PM"
372
373 loc = locale(locale("de_DE"), f);
374 cout.imbue(loc);
375 cout &lt;&lt; pt; // "31.10.2005 20:00:00"</pre></td></tr>
376 <tr>
377 <td rowspan="2" valign="top"><pre class="screen">%Y%m%dT%H%M%S%F%q</pre></td>
378 <td>ISO format</td>
379 </tr>
380 <tr><td><pre class="screen">"20051015T131211-0700" // Oct 15, 2005 13:12:11 MST</pre></td></tr>
381 <tr>
382 <td rowspan="2" valign="top"><pre class="screen">%Y-%m-%d %H:%M:%S%F%Q</pre></td>
383 <td>Extended ISO format</td>
384 </tr>
385 <tr><td><pre class="screen">"2005-10-15 13:12:11-07:00"</pre></td></tr>
386 <tr>
387 <td rowspan="2" valign="top"><pre class="screen">%Y-%b-%d %H:%M:%S%F %z</pre></td>
388 <td>Default format used when outputting ptime and local_date_time.</td>
389 </tr>
390 <tr><td><pre class="screen">"2005-Oct-15 13:12:11 MST"</pre></td></tr>
391 <tr>
392 <td rowspan="2" valign="top"><pre class="screen">%Y-%b-%d %H:%M:%S%F %ZP</pre></td>
393 <td>Default format used when inputting ptime and local_date_time.</td>
394 </tr>
395 <tr><td><pre class="screen">"2005-Oct-15 13:12:11 MST-07"</pre></td></tr>
396 <tr>
397 <td rowspan="2" valign="top"><pre class="screen">%-%H:%M:%S%F !</pre></td>
398 <td>Default time_duration format for output. Sign will only be displayed for negative durations.</td>
399 </tr>
400 <tr><td><pre class="screen">"-13:14:15.003400"</pre></td></tr>
401 <tr>
402 <td rowspan="2" valign="top"><pre class="screen">%H:%M:%S%F</pre></td>
403 <td>Default time_duration format for input.</td>
404 </tr>
405 <tr><td><pre class="screen">"13:14:15.003400"</pre></td></tr>
406 </tbody>
407 </table></div>
408 <p>
409   </p>
410 <p>* Signifies flags that have a behavior unique to <code class="computeroutput">date_time</code>.</p>
411 <p># Signifies flags that have a platform-dependent behavior. These may not be supported everywhere.</p>
412 <p>! Signifies flags that currently do not work for input.</p>
413 </div>
414 <p>The following table lists the available facets.</p>
415 <a name="io_objects_table"></a><h4>
416 <a name="idp180062528"></a>IO Objects</h4>
417 <p>
418     </p>
419 <div class="informaltable"><table class="table">
420 <colgroup>
421 <col>
422 <col>
423 </colgroup>
424 <thead><tr>
425 <th>Output</th>
426 <th>Input</th>
427 </tr></thead>
428 <tbody>
429 <tr>
430 <td><code class="computeroutput"><a class="link" href="../boost/date_time/date_facet.html" title="Class template date_facet">date_facet</a></code></td>
431 <td><code class="computeroutput"><a class="link" href="../boost/date_time/date_input_facet.html" title="Class template date_input_facet">date_input_facet</a></code></td>
432 </tr>
433 <tr>
434 <td><code class="computeroutput"><a class="link" href="../boost/date_time/date_facet.html" title="Class template date_facet">wdate_facet</a></code></td>
435 <td><code class="computeroutput"><a class="link" href="../boost/date_time/date_input_facet.html" title="Class template date_input_facet">wdate_input_facet</a></code></td>
436 </tr>
437 <tr>
438 <td><code class="computeroutput"><a class="link" href="../boost/date_time/time_facet.html" title="Class template time_facet">time_facet</a></code></td>
439 <td><code class="computeroutput"><a class="link" href="../boost/date_time/time_input_facet.html" title="Class template time_input_facet">time_input_facet</a></code></td>
440 </tr>
441 <tr>
442 <td><code class="computeroutput"><a class="link" href="../boost/date_time/time_facet.html" title="Class template time_facet">wtime_facet</a></code></td>
443 <td><code class="computeroutput"><a class="link" href="../boost/date_time/time_input_facet.html" title="Class template time_input_facet">wtime_input_facet</a></code></td>
444 </tr>
445 <tr>
446 <td>
447 <code class="computeroutput"><a class="link" href="../boost/date_time/time_facet.html" title="Class template time_facet">local_time_facet</a></code>*</td>
448 <td>
449 <code class="computeroutput"><a class="link" href="../boost/date_time/time_input_facet.html" title="Class template time_input_facet">local_time_input_facet</a></code>*</td>
450 </tr>
451 <tr>
452 <td>
453 <code class="computeroutput"><a class="link" href="../boost/date_time/time_facet.html" title="Class template time_facet">wlocal_time_facet</a></code>*</td>
454 <td>
455 <code class="computeroutput"><a class="link" href="../boost/date_time/time_input_facet.html" title="Class template time_input_facet">wlocal_time_input_facet</a></code>*</td>
456 </tr>
457 </tbody>
458 </table></div>
459 <p>
460     * These links lead to the <code class="computeroutput">time_facet</code> and <code class="computeroutput">time_input_facet</code> reference sections. They are not actual classes but typedefs.
461   </p>
462 <h4>
463 <a name="idp180088080"></a>Formatter/Parser Objects</h4>
464 <p>To implement the new i/o facets the date-time library uses a number of new parsers and formatters. These classes are available for users that want to implement specialized input/output routines.</p>
465 <p>
466     </p>
467 <div class="informaltable"><table class="table">
468 <colgroup>
469 <col>
470 <col>
471 </colgroup>
472 <thead><tr>
473 <th>Output</th>
474 <th>Input</th>
475 </tr></thead>
476 <tbody>
477 <tr>
478 <td><code class="computeroutput"><a class="link" href="../boost/date_time/period_formatter.html" title="Class template period_formatter">period_formatter</a></code></td>
479 <td><code class="computeroutput"><a class="link" href="../boost/date_time/period_parser.html" title="Class template period_parser">period_parser</a></code></td>
480 </tr>
481 <tr>
482 <td><code class="computeroutput"><a class="link" href="../boost/date_time/date_generator_formatter.html" title="Class template date_generator_formatter">date_generator_formatter</a></code></td>
483 <td><code class="computeroutput"><a class="link" href="../boost/date_time/date_generator_parser.html" title="Class template date_generator_parser">date_generator_parser</a></code></td>
484 </tr>
485 <tr>
486 <td><code class="computeroutput"><a class="link" href="../boost/date_time/special_values_formatter.html" title="Class template special_values_formatter">special_values_formatter</a></code></td>
487 <td><code class="computeroutput"><a class="link" href="../boost/date_time/special_values_parser.html" title="Class template special_values_parser">special_values_parser</a></code></td>
488 </tr>
489 <tr>
490 <td>&#160;</td>
491 <td><code class="computeroutput"><a class="link" href="../boost/date_time/format_date_parser.html" title="Class template format_date_parser">format_date_parser</a></code></td>
492 </tr>
493 </tbody>
494 </table></div>
495 <p>
496   </p>
497 <div class="section">
498 <div class="titlepage"><div><div><h3 class="title">
499 <a name="date_time.date_facet"></a>Date Facet</h3></div></div></div>
500 <a class="link" href="date_time_io.html#date_facet_intro">Introduction</a> -
501   <a class="link" href="date_time_io.html#date_facet_constr">Construction</a> -
502   <a class="link" href="date_time_io.html#date_facet_accessors">Accessors</a><a name="date_facet_intro"></a><h4>
503 <a name="idp180110384"></a>Introduction</h4>
504 <p>The <code class="computeroutput">boost::date_time::date_facet</code> enables users to have significant control over the output streaming of dates (and other gregorian objects). The date_facet is typedef'd in the <code class="computeroutput">gregorian</code> namespace as <code class="computeroutput">date_facet</code> and <code class="computeroutput">wdate_facet</code>. 
505   </p>
506 <a name="date_facet_constr"></a><h4>
507 <a name="idp180115200"></a>Construction</h4>
508 <p>
509     </p>
510 <div class="informaltable"><table class="table">
511 <colgroup>
512 <col>
513 <col>
514 </colgroup>
515 <thead><tr>
516 <th>Syntax</th>
517 <th>Description</th>
518 </tr></thead>
519 <tbody>
520 <tr>
521 <td valign="top"><pre class="screen">date_facet()</pre></td>
522 <td>Default constructor</td>
523 </tr>
524 <tr>
525 <td valign="top"><pre class="screen">date_facet(...)
526   Parameters:
527     char_type* format
528     input_collection_type</pre></td>
529 <td>Format given will be used for date output. All other formats will use their defaults. Collection is the set of short names to be used for months. All other name collections will use their defaults.</td>
530 </tr>
531 <tr>
532 <td valign="top"><pre class="screen">date_facet(...)
533   Parameters:
534     char_type* format
535     period_formatter_type
536     special_values_formatter_type
537     date_gen_formatter_type</pre></td>
538 <td>Format given will be used for date output. The remaining parameters are formatter objects. Further details on these objects can be found <a class="link" href="date_time_io.html#date_time.io_objects" title="Date Time Formatter/Parser Objects">here</a>. This constructor also provides default arguments for all parameters except the format. Therefore, <code class="computeroutput">date_facet("%m %d %Y")</code> will work.</td>
539 </tr>
540 </tbody>
541 </table></div>
542 <p>
543   </p>
544 <a name="date_facet_accessors"></a><h4>
545 <a name="idp180128064"></a>Accessors</h4>
546 <p>
547     </p>
548 <div class="informaltable"><table class="table">
549 <colgroup>
550 <col>
551 <col>
552 </colgroup>
553 <thead>
554 <tr>
555 <th rowspan="2" valign="top">Syntax</th>
556 <th>Description</th>
557 </tr>
558 <tr><th>Example</th></tr>
559 </thead>
560 <tbody>
561 <tr>
562 <td rowspan="2" valign="top"><pre class="screen">void format(char_type*)</pre></td>
563 <td>Set the format for dates.</td>
564 </tr>
565 <tr><td><pre class="screen">date_facet* f = new date_facet();
566 f-&gt;format("%m %d %Y");</pre></td></tr>
567 <tr>
568 <td rowspan="2" valign="top"><pre class="screen">void set_iso_format()</pre></td>
569 <td>Sets the date format to ISO</td>
570 </tr>
571 <tr><td><pre class="screen">f-&gt;set_iso_format();
572 // "%Y%m%d"</pre></td></tr>
573 <tr>
574 <td rowspan="2" valign="top"><pre class="screen">void set_iso_extended_format()</pre></td>
575 <td>Sets the date format to ISO Extended</td>
576 </tr>
577 <tr><td><pre class="screen">f-&gt;set_iso_extended_format();
578 // "%Y-%m-%d"</pre></td></tr>
579 <tr>
580 <td rowspan="2" valign="top"><pre class="screen">void month_format(char_type*)</pre></td>
581 <td>Set the format for months when they are 'put' individually.</td>
582 </tr>
583 <tr><td><pre class="screen">f-&gt;month_format("%B"); 
584 ss &lt;&lt; greg_month(12); // "December"</pre></td></tr>
585 <tr>
586 <td rowspan="2" valign="top"><pre class="screen">void weekday_format(char_type*)</pre></td>
587 <td>Set the format for weekdays when they are 'put' individually.</td>
588 </tr>
589 <tr><td><pre class="screen">f-&gt;weekday_format("%a");
590 ss &lt;&lt; greg_weekday(2); // "Tue"</pre></td></tr>
591 <tr>
592 <td rowspan="2" valign="top"><pre class="screen">void period_formatter(...)
593   Parameter:
594     period_formatter_type</pre></td>
595 <td>Replaces the period formatter object with a user created one.</td>
596 </tr>
597 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
598 <tr>
599 <td rowspan="2" valign="top"><pre class="screen">void special_values_formatter(...)
600   Parameter:
601     special_values_formatter_type</pre></td>
602 <td>Replaces the special_values formatter object with a user created one.</td>
603 </tr>
604 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
605 <tr>
606 <td rowspan="2" valign="top"><pre class="screen">void date_gen_phrase_strings(...)
607   Parameters:
608     input_collection_type
609     date_gen_formatter_type::
610       phrase_elements</pre></td>
611 <td>Sets new date generator phrase strings in date_gen_formatter. The input collection is a vector of strings (for details on these strings see <a class="link" href="date_time_io.html#io_objects.date_generators">date generator formatter/parser documentation</a>). The phrase_elements parameter is an enum, defined in the date_generator_formatter object, that has a default value of 'first'. It is used to indicate what the position of the first string in the collection will be.</td>
612 </tr>
613 <tr><td><pre class="screen"></pre></td></tr>
614 <tr>
615 <td rowspan="2" valign="top"><pre class="screen">void short_weekday_names(...)
616   Parameter:
617     input_collection_type</pre></td>
618 <td>Replace strings used when 'putting' short weekdays.</td>
619 </tr>
620 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
621 <tr>
622 <td rowspan="2" valign="top"><pre class="screen">void long_weekday_names(...)
623   Parameter:
624     input_collection_type</pre></td>
625 <td>Replace strings used when 'putting' long weekdays.</td>
626 </tr>
627 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
628 <tr>
629 <td rowspan="2" valign="top"><pre class="screen">void short_month_names(...)
630   Parameter:
631     input_collection_type</pre></td>
632 <td>Replace strings used when 'putting' short months.</td>
633 </tr>
634 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
635 <tr>
636 <td rowspan="2" valign="top"><pre class="screen">void long_month_names(...)
637   Parameter:
638     input_collection_type</pre></td>
639 <td>Replace strings used when 'putting' long months.</td>
640 </tr>
641 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
642 <tr>
643 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(...)
644   Common parameters for all 
645   'put' functions:
646     OutItrT 
647     ios_base
648     char_type
649   Unique parameter for 'put' funcs:
650     gregorian object</pre></td>
651 <td>There are 12 put functions in the date_facet. The common paraeters are: an iterator pointing to the next item in the stream, an ios_base object, and the fill character. Each unique gregorian object has it's own put function. Each unique put function is described below.</td>
652 </tr>
653 <tr><td><pre class="screen"></pre></td></tr>
654 <tr>
655 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., date)</pre></td>
656 <td>Puts a date object into the stream using the format set by <code class="computeroutput">format(...)</code> or the default.</td>
657 </tr>
658 <tr><td><pre class="screen"></pre></td></tr>
659 <tr>
660 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., days)</pre></td>
661 <td>Puts a days object into the stream as a number.</td>
662 </tr>
663 <tr><td><pre class="screen"></pre></td></tr>
664 <tr>
665 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., month)</pre></td>
666 <td>Puts a month object into the stream using the format set by <code class="computeroutput">month_format(...)</code> or the default.</td>
667 </tr>
668 <tr><td><pre class="screen"></pre></td></tr>
669 <tr>
670 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., day)</pre></td>
671 <td>Puts a day of month object into the stream as a two digit number.</td>
672 </tr>
673 <tr><td><pre class="screen">"01" // January 1st</pre></td></tr>
674 <tr>
675 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., day_of_week)</pre></td>
676 <td>Puts a day of week object into the stream using the format set by <code class="computeroutput">weekday_format(...)</code> or the default.</td>
677 </tr>
678 <tr><td><pre class="screen"></pre></td></tr>
679 <tr>
680 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., date_period)</pre></td>
681 <td>Puts a date_period into the stream. The format of the dates will use the format set by <code class="computeroutput">format(..)</code> or the default date format. The type of period (open or closed range) and the delimiters used are those used by the period_formatter.</td>
682 </tr>
683 <tr><td><pre class="screen"></pre></td></tr>
684 <tr>
685 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., partial_date)</pre></td>
686 <td>Puts a partial_date date_generator object into the stream. The month format used is set by <code class="computeroutput">month_format(..)</code> or the default. The day of month is represented as a two digit number.</td>
687 </tr>
688 <tr><td><pre class="screen">"01 Jan" // default formats
689 "01 January" // long month format</pre></td></tr>
690 <tr>
691 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., date_generator)
692   Date Generator Type:
693     nth_day_of_the_week_in_month</pre></td>
694 <td>Puts a nth_day_of_the_week_in_month object into the stream. The month format is set by <code class="computeroutput">month_format(...)</code> or the default. The weekday format is set by <code class="computeroutput">weekday_format(...)</code> or the default. The remaining phrase elements are set in the <a class="link" href="date_time_io.html#io_objects.date_generators">date_generator_formatter</a>.</td>
695 </tr>
696 <tr><td><pre class="screen">"third Fri in May" // defaults</pre></td></tr>
697 <tr>
698 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., date_generator)
699   Date Generator Type:
700     first_day_of_the_week_in_month</pre></td>
701 <td>Puts a first_day_of_the_week_in_month object into the stream. The month format is set by <code class="computeroutput">month_format(...)</code> or the default. The weekday format is set by <code class="computeroutput">weekday_format(...)</code> or the default. The remaining phrase elements are set in the <a class="link" href="date_time_io.html#io_objects.date_generators">date_generator_formatter</a>.</td>
702 </tr>
703 <tr><td><pre class="screen">"first Wed of Jun" // defaults</pre></td></tr>
704 <tr>
705 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., date_generator)
706   Date Generator Type:
707     last_day_of_the_week_in_month</pre></td>
708 <td>Puts a last_day_of_the_week_in_month object into the stream. The month format is set by <code class="computeroutput">month_format(...)</code> or the default. The weekday format is set by <code class="computeroutput">weekday_format(...)</code> or the default. The remaining phrase elements are set in the <a class="link" href="date_time_io.html#io_objects.date_generators">date_generator_formatter</a>.</td>
709 </tr>
710 <tr><td><pre class="screen">"last Tue of Mar" // defaults</pre></td></tr>
711 <tr>
712 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., date_generator)
713   Date Generator Type:
714     first_day_of_the_week_after</pre></td>
715 <td>Puts a first_day_of_the_week_after object into the stream. The weekday format is set by <code class="computeroutput">weekday_format(...)</code> or the default. The remaining phrase elements are set in the <a class="link" href="date_time_io.html#io_objects.date_generators">date_generator_formatter</a>.</td>
716 </tr>
717 <tr><td><pre class="screen">"first Sat after" // defaults</pre></td></tr>
718 <tr>
719 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., date_generator)
720   Date Generator Type:
721     first_day_of_the_week_before</pre></td>
722 <td>Puts a first_day_of_the_week_before object into the stream. The weekday format is set by <code class="computeroutput">weekday_format(...)</code> or the default. The remaining phrase elements are set in the <a class="link" href="date_time_io.html#io_objects.date_generators">date_generator_formatter</a>.</td>
723 </tr>
724 <tr><td><pre class="screen">"first Mon before" // defaults</pre></td></tr>
725 </tbody>
726 </table></div>
727 <p>
728   </p>
729 </div>
730 <div class="section">
731 <div class="titlepage"><div><div><h3 class="title">
732 <a name="date_time.date_input_facet"></a>Date Input Facet</h3></div></div></div>
733 <a class="link" href="date_time_io.html#date_input_facet_intro">Introduction</a> -
734   <a class="link" href="date_time_io.html#date_input_facet_constr">Construction</a> -
735   <a class="link" href="date_time_io.html#date_input_facet_accessors">Accessors</a><a name="date_input_facet_intro"></a><h4>
736 <a name="idp180241216"></a>Introduction</h4>
737 <p>The <code class="computeroutput">boost::date_time::date_input_facet</code> enables users to have significant control how dates (and other gregorian objects) are streamed in. The date_input_facet is typedef'd in the <code class="computeroutput">gregorian</code> namespace as <code class="computeroutput">date_input_facet</code> and <code class="computeroutput">wdate_input_facet</code>. 
738   </p>
739 <a name="date_input_facet_constr"></a><h4>
740 <a name="idp180245984"></a>Construction</h4>
741 <p>
742     </p>
743 <div class="informaltable"><table class="table">
744 <colgroup>
745 <col>
746 <col>
747 </colgroup>
748 <thead><tr>
749 <th>Syntax</th>
750 <th>Description</th>
751 </tr></thead>
752 <tbody>
753 <tr>
754 <td valign="top"><pre class="screen">date_input_facet()</pre></td>
755 <td>Default constructor</td>
756 </tr>
757 <tr>
758 <td valign="top"><pre class="screen">date_input_facet(string_type format)</pre></td>
759 <td>Format given will be used for date input. All other formats will use their defaults.</td>
760 </tr>
761 <tr>
762 <td valign="top"><pre class="screen">date_input_facet(...)
763   Parameters:
764     string_type format
765     format_date_parser_type
766     special_values_parser_type
767     period_parser_type
768     date_gen_parser_type</pre></td>
769 <td>Format given will be used for date input. The remaining parameters are parser objects. Further details on these objects can be found <a class="link" href="date_time_io.html#date_time.io_objects" title="Date Time Formatter/Parser Objects">here</a>.</td>
770 </tr>
771 </tbody>
772 </table></div>
773 <p>
774   </p>
775 <a name="date_input_facet_accessors"></a><h4>
776 <a name="idp180257728"></a>Accessors</h4>
777 <p>
778     </p>
779 <div class="informaltable"><table class="table">
780 <colgroup>
781 <col>
782 <col>
783 </colgroup>
784 <thead>
785 <tr>
786 <th rowspan="2" valign="top">Syntax</th>
787 <th>Description</th>
788 </tr>
789 <tr><th>Example</th></tr>
790 </thead>
791 <tbody>
792 <tr>
793 <td rowspan="2" valign="top"><pre class="screen">void format(char_type*)</pre></td>
794 <td>Set the format for dates.</td>
795 </tr>
796 <tr><td><pre class="screen">date_input_facet* f = 
797     new date_input_facet();
798 f-&gt;format("%m %d %Y");</pre></td></tr>
799 <tr>
800 <td rowspan="2" valign="top"><pre class="screen">void set_iso_format()</pre></td>
801 <td>Sets the date format to ISO</td>
802 </tr>
803 <tr><td><pre class="screen">f-&gt;set_iso_format();
804 // "%Y%m%d"</pre></td></tr>
805 <tr>
806 <td rowspan="2" valign="top"><pre class="screen">void set_iso_extended_format()</pre></td>
807 <td>Sets the date format to ISO Extended</td>
808 </tr>
809 <tr><td><pre class="screen">f-&gt;set_iso_extended_format();
810 // "%Y-%m-%d"</pre></td></tr>
811 <tr>
812 <td rowspan="2" valign="top"><pre class="screen">void month_format(char_type*)</pre></td>
813 <td>Set the format when 'get'ing months individually.</td>
814 </tr>
815 <tr><td><pre class="screen">f-&gt;month_format("%B");
816 ss.str("March");
817 ss &gt;&gt; m; // March</pre></td></tr>
818 <tr>
819 <td rowspan="2" valign="top"><pre class="screen">void weekday_format(char_type*)</pre></td>
820 <td>Set the format when 'get'ing weekdays individually.</td>
821 </tr>
822 <tr><td><pre class="screen">f-&gt;weekday_format("%a");
823 ss.str("Sun");
824 ss &gt;&gt; wd; // Sunday</pre></td></tr>
825 <tr>
826 <td rowspan="2" valign="top"><pre class="screen">void year_format(char_type*)</pre></td>
827 <td>Set the format when 'get'ing years individually.</td>
828 </tr>
829 <tr><td><pre class="screen">f-&gt;weekday_format("%y");
830 ss.str("04");
831 ss &gt;&gt; year; // 2004</pre></td></tr>
832 <tr>
833 <td rowspan="2" valign="top"><pre class="screen">void period_parser(...)
834   Parameter:
835     period_parser_type</pre></td>
836 <td>Replaces the period parser object with a user created one.</td>
837 </tr>
838 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
839 <tr>
840 <td rowspan="2" valign="top"><pre class="screen">void special_values_parser(...)
841   Parameter:
842     special_values_parser_type</pre></td>
843 <td>Replaces the special_values parser object with a user created one.</td>
844 </tr>
845 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
846 <tr>
847 <td rowspan="2" valign="top"><pre class="screen">void date_gen_phrase_strings(...)
848   Parameters:
849     input_collection_type</pre></td>
850 <td>Sets new date generator phrase strings in date_gen_parser. The input collection is a vector of strings (for details on these strings see <a class="link" href="date_time_io.html#io_objects.date_generators">date generator formatter/parser documentation</a>).</td>
851 </tr>
852 <tr><td><pre class="screen"></pre></td></tr>
853 <tr>
854 <td rowspan="2" valign="top"><pre class="screen">void short_weekday_names(...)
855   Parameter:
856     input_collection_type</pre></td>
857 <td>Replace strings used when 'getting' short weekdays.</td>
858 </tr>
859 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
860 <tr>
861 <td rowspan="2" valign="top"><pre class="screen">void long_weekday_names(...)
862   Parameter:
863     input_collection_type</pre></td>
864 <td>Replace strings used when 'getting' long weekdays.</td>
865 </tr>
866 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
867 <tr>
868 <td rowspan="2" valign="top"><pre class="screen">void short_month_names(...)
869   Parameter:
870     input_collection_type</pre></td>
871 <td>Replace strings used when 'getting' short months.</td>
872 </tr>
873 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
874 <tr>
875 <td rowspan="2" valign="top"><pre class="screen">void long_month_names(...)
876   Parameter:
877     input_collection_type</pre></td>
878 <td>Replace strings used when 'getting' long months.</td>
879 </tr>
880 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
881 <tr>
882 <td rowspan="2" valign="top"><pre class="screen">InItrT get(...)
883   Common parameters for all 
884   'get' functions:
885     InItrT from
886     InItrT to
887     ios_base
888   Unique parameter for 'get' funcs:
889     gregorian object</pre></td>
890 <td>There are 13 get functions in the date_input_facet. The common parameters are: an iterator pointing to the begining of the stream, an iterator pointing to the end of the stream, and an ios_base object. Each unique gregorian object has it's own get function. Each unique get function is described below.</td>
891 </tr>
892 <tr><td><pre class="screen"></pre></td></tr>
893 <tr>
894 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., date)</pre></td>
895 <td>Gets a date object from the stream using the format set by <code class="computeroutput">format(...)</code> or the default.</td>
896 </tr>
897 <tr><td><pre class="screen">ss.str("2005-Jan-01");
898 ss &gt;&gt; d; // default format</pre></td></tr>
899 <tr>
900 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., month)</pre></td>
901 <td>Gets a month object from the stream using the format set by <code class="computeroutput">month_format(...)</code> or the default.</td>
902 </tr>
903 <tr><td><pre class="screen">ss.str("Feb");
904 ss &gt;&gt; m; // default format</pre></td></tr>
905 <tr>
906 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., day_of_week)</pre></td>
907 <td>Gets a day of week object from the stream using the format set by <code class="computeroutput">weekday_format(...)</code> or the default.</td>
908 </tr>
909 <tr><td><pre class="screen">ss.str("Sun");
910 ss &gt;&gt; dow; // default format</pre></td></tr>
911 <tr>
912 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., day)</pre></td>
913 <td>Gets a day of month object from the stream as a two digit number.</td>
914 </tr>
915 <tr><td><pre class="screen">"01" // January 1st</pre></td></tr>
916 <tr>
917 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., year)</pre></td>
918 <td>Gets a year object from the stream as a number. The number of expected digits depends on the year format.</td>
919 </tr>
920 <tr><td><pre class="screen">ss/str("2005");
921 ss &gt;&gt; y; // default format</pre></td></tr>
922 <tr>
923 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., days)</pre></td>
924 <td>Gets a days object from the stream as a number.</td>
925 </tr>
926 <tr><td><pre class="screen">ss.str("356");
927 ss &gt;&gt; dys; // a full year</pre></td></tr>
928 <tr>
929 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., date_period)</pre></td>
930 <td>Gets a date_period from the stream. The format of the dates will use the format set by <code class="computeroutput">format(..)</code> or the default date format. The type of period (open or closed range) and the delimiters used are those used by the period_parser.</td>
931 </tr>
932 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
933 <tr>
934 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., partial_date)</pre></td>
935 <td>Gets a partial_date date_generator object from the stream. The month format used is set by <code class="computeroutput">month_format(..)</code> or the default. The day of month is represented as a two digit number.</td>
936 </tr>
937 <tr><td><pre class="screen">"01 Jan" // default formats
938 "01 January" // long month format</pre></td></tr>
939 <tr>
940 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., date_generator)
941   Date Generator Type:
942     nth_day_of_the_week_in_month</pre></td>
943 <td>Gets a nth_day_of_the_week_in_month object from the stream. The month format is set by <code class="computeroutput">month_format(...)</code> or the default. The weekday format is set by <code class="computeroutput">weekday_format(...)</code> or the default. The remaining phrase elements are set in the <a class="link" href="date_time_io.html#io_objects.date_generators">date_generator_parser</a>.</td>
944 </tr>
945 <tr><td><pre class="screen">"third Fri in May" // defaults</pre></td></tr>
946 <tr>
947 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., date_generator)
948   Date Generator Type:
949     first_day_of_the_week_in_month</pre></td>
950 <td>Gets a first_day_of_the_week_in_month object from the stream. The month format is set by <code class="computeroutput">month_format(...)</code> or the default. The weekday format is set by <code class="computeroutput">weekday_format(...)</code> or the default. The remaining phrase elements are set in the <a class="link" href="date_time_io.html#io_objects.date_generators">date_generator_parser</a>.</td>
951 </tr>
952 <tr><td><pre class="screen">"first Wed of Jun" // defaults</pre></td></tr>
953 <tr>
954 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., date_generator)
955   Date Generator Type:
956     last_day_of_the_week_in_month</pre></td>
957 <td>Gets a last_day_of_the_week_in_month object from the stream. The month format is set by <code class="computeroutput">month_format(...)</code> or the default. The weekday format is set by <code class="computeroutput">weekday_format(...)</code> or the default. The remaining phrase elements are set in the <a class="link" href="date_time_io.html#io_objects.date_generators">date_generator_parser</a>.</td>
958 </tr>
959 <tr><td><pre class="screen">"last Tue of Mar" // defaults</pre></td></tr>
960 <tr>
961 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., date_generator)
962   Date Generator Type:
963     first_day_of_the_week_after</pre></td>
964 <td>Gets a first_day_of_the_week_after object from the stream. The weekday format is set by <code class="computeroutput">weekday_format(...)</code> or the default. The remaining phrase elements are set in the <a class="link" href="date_time_io.html#io_objects.date_generators">date_generator_parser</a>.</td>
965 </tr>
966 <tr><td><pre class="screen">"first Sat after" // defaults</pre></td></tr>
967 <tr>
968 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., date_generator)
969   Date Generator Type:
970     first_day_of_the_week_before</pre></td>
971 <td>Gets a first_day_of_the_week_before object from the stream. The weekday format is set by <code class="computeroutput">weekday_format(...)</code> or the default. The remaining phrase elements are set in the <a class="link" href="date_time_io.html#io_objects.date_generators">date_generator_parser</a>.</td>
972 </tr>
973 <tr><td><pre class="screen">"first Mon before" // defaults</pre></td></tr>
974 </tbody>
975 </table></div>
976 <p>
977   </p>
978 </div>
979 <div class="section">
980 <div class="titlepage"><div><div><h3 class="title">
981 <a name="date_time.time_facet"></a>Time Facet</h3></div></div></div>
982 <a class="link" href="date_time_io.html#time_facet_intro">Introduction</a> -
983   <a class="link" href="date_time_io.html#time_facet_constr">Construction</a> -
984   <a class="link" href="date_time_io.html#time_facet_accessors">Accessors</a><a name="time_facet_intro"></a><h4>
985 <a name="idp180378512"></a>Introduction</h4>
986 <p>The <code class="computeroutput">boost::date_time::time_facet</code> is an extension of the <code class="computeroutput">boost::date_time::date_facet</code>. The time_facet is typedef'ed in the <code class="computeroutput">posix_time</code> namespace as <code class="computeroutput">time_facet</code> and <code class="computeroutput">wtime_facet</code>. It is typedef'd in the <code class="computeroutput">local_time</code> namespace as <code class="computeroutput">local_time_facet</code> and <code class="computeroutput">wlocal_time_facet</code>.
987   </p>
988 <a name="time_facet_constr"></a><h4>
989 <a name="idp180386144"></a>Construction</h4>
990 <p>
991     </p>
992 <div class="informaltable"><table class="table">
993 <colgroup>
994 <col>
995 <col>
996 </colgroup>
997 <thead><tr>
998 <th>Syntax</th>
999 <th>Description</th>
1000 </tr></thead>
1001 <tbody>
1002 <tr>
1003 <td valign="top"><pre class="screen">time_facet()</pre></td>
1004 <td>Default constructor</td>
1005 </tr>
1006 <tr>
1007 <td valign="top"><pre class="screen">time_facet(...)
1008   Parameters:
1009     char_type* format
1010     period_formatter_type
1011     special_values_formatter_type
1012     date_gen_formatter_type</pre></td>
1013 <td>Format given will be used for time output. The remaining parameters are formatter objects. Further details on these objects can be found <a class="link" href="date_time_io.html#date_time.io_objects" title="Date Time Formatter/Parser Objects">here</a>. This constructor also provides default arguments for all parameters except the format. Therefore, <code class="computeroutput">time_facet("%H:%M:S %m %d %Y")</code> will work.</td>
1014 </tr>
1015 </tbody>
1016 </table></div>
1017 <p>
1018   </p>
1019 <a name="time_facet_accessors"></a><h4>
1020 <a name="idp180396752"></a>Accessors</h4>
1021 <p>
1022     The time_facet inherits all the public date_facet methods. Therefore, the date_facet methods are not listed here. Instead, they can be found by following <a class="link" href="date_time_io.html#date_time.date_facet" title="Date Facet">this</a> link.
1023     </p>
1024 <div class="informaltable"><table class="table">
1025 <colgroup>
1026 <col>
1027 <col>
1028 </colgroup>
1029 <thead>
1030 <tr>
1031 <th rowspan="2" valign="top">Syntax</th>
1032 <th>Description</th>
1033 </tr>
1034 <tr><th>Example</th></tr>
1035 </thead>
1036 <tbody>
1037 <tr>
1038 <td rowspan="2" valign="top"><pre class="screen">void time_duration_format(...)
1039   Parameter:
1040     char_type*</pre></td>
1041 <td>Sets the time_duration format. The time_duration format has the ability to display the sign of the duration. The <code class="computeroutput">'%+'</code> flag will always display the sign. The <code class="computeroutput">'%-'</code> will only display if the sign is negative. Currently the '-' and '+' characters are used to denote the sign.</td>
1042 </tr>
1043 <tr><td><pre class="screen">f-&gt;time_duration_format("%+%H:%M");
1044 // hours and minutes only w/ sign always displayed
1045 time_duration td1(3, 15, 56);
1046 time_duration td2(-12, 25, 32);
1047 ss &lt;&lt; td1; // "+03:15:56"
1048 ss &lt;&lt; td2; // "-12:25:56"
1049             </pre></td></tr>
1050 <tr>
1051 <td rowspan="2" valign="top"><pre class="screen">void set_iso_format()</pre></td>
1052 <td>Sets the date and time format to ISO.</td>
1053 </tr>
1054 <tr><td><pre class="screen">f-&gt;set_iso_format();
1055 // "%Y%m%dT%H%M%S%F%q"</pre></td></tr>
1056 <tr>
1057 <td rowspan="2" valign="top"><pre class="screen">void set_iso_extended_format()</pre></td>
1058 <td>Sets the date and time format to ISO Extended</td>
1059 </tr>
1060 <tr><td><pre class="screen">f-&gt;set_iso_extended_format();
1061 // "%Y-%m-%d %H:%M:%S%F%Q"</pre></td></tr>
1062 <tr>
1063 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(...)
1064   Common parameters for all 
1065   'put' functions:
1066     OutItrT 
1067     ios_base
1068     char_type
1069   Unique parameter for 'put' funcs:
1070     posix_time object</pre></td>
1071 <td>There are 3 put functions in the time_facet. The common parameters are: an iterator pointing to the next item in the stream, an ios_base object, and the fill character. Each unique posix_time object has it's own put function. Each unique put function is described below.</td>
1072 </tr>
1073 <tr><td><pre class="screen"></pre></td></tr>
1074 <tr>
1075 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., ptime)</pre></td>
1076 <td>Puts a ptime object into the stream using the format set by <code class="computeroutput">format(...)</code> or the default.</td>
1077 </tr>
1078 <tr><td><pre class="screen"></pre></td></tr>
1079 <tr>
1080 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., time_duration)</pre></td>
1081 <td>Puts a time_duration object into the stream using the format set by <code class="computeroutput">time_duration_format(...)</code> or the default.</td>
1082 </tr>
1083 <tr><td><pre class="screen"></pre></td></tr>
1084 <tr>
1085 <td rowspan="2" valign="top"><pre class="screen">OutItrT put(..., time_period)</pre></td>
1086 <td>Puts a time_period into the stream. The format of the dates and times will use the format set by <code class="computeroutput">format(..)</code> or the default date/time format. The type of period (open or closed range) and the delimiters used are those used by the period_formatter.</td>
1087 </tr>
1088 <tr><td><pre class="screen"></pre></td></tr>
1089 </tbody>
1090 </table></div>
1091 <p>
1092   </p>
1093 </div>
1094 <div class="section">
1095 <div class="titlepage"><div><div><h3 class="title">
1096 <a name="date_time.time_input_facet"></a>Time Input Facet</h3></div></div></div>
1097 <a class="link" href="date_time_io.html#time_input_facet_intro">Introduction</a> -
1098   <a class="link" href="date_time_io.html#time_input_facet_constr">Construction</a> -
1099   <a class="link" href="date_time_io.html#time_input_facet_accessors">Accessors</a><a name="time_input_facet_intro"></a><h4>
1100 <a name="idp180436096"></a>Introduction</h4>
1101 <p>The <code class="computeroutput">boost::date_time::time_input_facet</code> is an extension of the <code class="computeroutput">date_input_facet</code>. It is typedef'ed in the <code class="computeroutput">boost::posix_time</code> namespace as <code class="computeroutput">time_input_facet</code> and <code class="computeroutput">wtime_input_facet</code>. It is typedef'ed in the <code class="computeroutput">boost::local_time</code> namespace as <code class="computeroutput">local_time_input_facet</code> and <code class="computeroutput">wlocal_time_input_facet</code>.
1102   </p>
1103 <a name="time_input_facet_constr"></a><h4>
1104 <a name="idp180443664"></a>Construction</h4>
1105 <p>
1106     </p>
1107 <div class="informaltable"><table class="table">
1108 <colgroup>
1109 <col>
1110 <col>
1111 </colgroup>
1112 <thead><tr>
1113 <th>Syntax</th>
1114 <th>Description</th>
1115 </tr></thead>
1116 <tbody>
1117 <tr>
1118 <td valign="top"><pre class="screen">time_input_facet()</pre></td>
1119 <td>Default constructor</td>
1120 </tr>
1121 <tr>
1122 <td valign="top"><pre class="screen">time_input_facet(string_type)</pre></td>
1123 <td>Format given will be used for date/time input. All other formats will use their defaults.</td>
1124 </tr>
1125 <tr>
1126 <td valign="top"><pre class="screen">time_input_facet(...)
1127   Parameters:
1128     string_type format
1129     format_date_parser_type
1130     special_values_parser_type
1131     period_parser_type
1132     date_gen_parser_type</pre></td>
1133 <td>Format given will be used for date/time input. The remaining parameters are parser objects. Further details on these objects can be found <a class="link" href="date_time_io.html#date_time.io_objects" title="Date Time Formatter/Parser Objects">here</a>.</td>
1134 </tr>
1135 </tbody>
1136 </table></div>
1137 <p>
1138   </p>
1139 <a name="time_input_facet_accessors"></a><h4>
1140 <a name="idp180455440"></a>Accessors</h4>
1141 <p>
1142     The time_input_facet inherits all the public date_input_facet methods. Therefore, the date_input_facet methods are not listed here. Instead, they can be found by following <a class="link" href="date_time_io.html#date_time.date_input_facet" title="Date Input Facet">this</a> link.
1143     </p>
1144 <div class="informaltable"><table class="table">
1145 <colgroup>
1146 <col>
1147 <col>
1148 </colgroup>
1149 <thead>
1150 <tr>
1151 <th rowspan="2" valign="top">Syntax</th>
1152 <th>Description</th>
1153 </tr>
1154 <tr><th>Example</th></tr>
1155 </thead>
1156 <tbody>
1157 <tr>
1158 <td rowspan="2" valign="top"><pre class="screen">void set_iso_format()</pre></td>
1159 <td>Sets the time format to ISO</td>
1160 </tr>
1161 <tr><td><pre class="screen">f-&gt;set_iso_format();
1162 // "%Y%m%dT%H%M%S%F%q"
1163 "20051225T132536.789-0700"</pre></td></tr>
1164 <tr>
1165 <td rowspan="2" valign="top"><pre class="screen">void set_iso_extended_format()</pre></td>
1166 <td>Sets the date format to ISO Extended</td>
1167 </tr>
1168 <tr><td><pre class="screen">f-&gt;set_iso_extended_format();
1169 // "%Y-%m-%d %H:%M:%S%F %Q"
1170 "2005-12-25 13:25:36.789 -07:00"</pre></td></tr>
1171 <tr>
1172 <td rowspan="2" valign="top"><pre class="screen">void time_duration_format(...)
1173   Parameter:
1174     char_type*</pre></td>
1175 <td>Sets the time_duration format.</td>
1176 </tr>
1177 <tr><td><pre class="screen">f-&gt;time_duration_format("%H:%M");
1178 // hours and minutes only</pre></td></tr>
1179 <tr>
1180 <td rowspan="2" valign="top"><pre class="screen">InItrT get(...)
1181   Common parameters for all 
1182   'get' functions:
1183     InItrT from
1184     InItrT to
1185     ios_base
1186   Unique parameter for 'get' funcs:
1187     gregorian object</pre></td>
1188 <td>There are 3 get functions in the time_input_facet. The common parameters are: an iterator pointing to the begining of the stream, an iterator pointing to the end of the stream, and an ios_base object. Each unique gregorian object has it's own get function. Each unique get function is described below.</td>
1189 </tr>
1190 <tr><td><pre class="screen"></pre></td></tr>
1191 <tr>
1192 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., ptime)</pre></td>
1193 <td>Gets a ptime object from the stream using the format set by <code class="computeroutput">format(...)</code> or the default.</td>
1194 </tr>
1195 <tr><td><pre class="screen">ss.str("2005-Jan-01 13:12:01");
1196 ss &gt;&gt; pt; // default format</pre></td></tr>
1197 <tr>
1198 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., time_duration)</pre></td>
1199 <td>Gets a time_duration object from the stream using the format set by <code class="computeroutput">time_duration_format(...)</code> or the default.</td>
1200 </tr>
1201 <tr><td><pre class="screen">ss.str("01:25:15.000123000");
1202 ss &gt;&gt; td; // default format</pre></td></tr>
1203 <tr>
1204 <td rowspan="2" valign="top"><pre class="screen">InItrT get(..., time_period)</pre></td>
1205 <td>Gets a time_period from the stream. The format of the dates/times will use the format set by <code class="computeroutput">format(..)</code> or the default date and time format. The type of period (open or closed range) and the delimiters used are those used by the period_parser.</td>
1206 </tr>
1207 <tr><td>see the <a class="link" href="date_time_io.html#date_time.io_tutorial" title="Date Time IO Tutorial">tutorial</a> for a complete example.</td></tr>
1208 </tbody>
1209 </table></div>
1210 <p>
1211   </p>
1212 </div>
1213 <div class="section">
1214 <div class="titlepage"><div><div><h3 class="title">
1215 <a name="date_time.io_objects"></a>Date Time Formatter/Parser Objects</h3></div></div></div>
1216 <h3>
1217 <a name="idp180490496"></a>Date Time Formatter/Parser Objects</h3>
1218 <a class="link" href="date_time_io.html#io_objects.periods">Periods</a> |
1219   <a class="link" href="date_time_io.html#io_objects.date_generators">Date Generators</a> |
1220   <a class="link" href="date_time_io.html#io_objects.special_values">Special Values</a> |
1221   <a class="link" href="date_time_io.html#io_objects.format_date_parser">Format Date Parser</a><a name="io_objects.periods"></a><h4>
1222 <a name="idp180495856"></a>Periods</h4>
1223 <p>The period_formatter and period_parser provide a uniform interface for the input and output of date_periods, time_periods, and in a future release, local_date_time_periods. The user has control over the delimiters, formats of the date/time components, and the form the period takes. The format of the date/time components is controlled via the date_time input and output facets.</p>
1224 <h5>
1225 <a name="idp180497296"></a>Period Form</h5>
1226 <p>Periods are constructed with open ranged parameters. The first value is the starting point, and is included in the period. The end value is not included but immediately follows the last value: [begin/end). However, a period can be streamed as either an open range or a closed range.</p>
1227 <pre class="screen">[2003-Jan-01/2003-Dec-31] &lt;-- period holding 365 days
1228 [2003-Jan-01/2004-Jan-01) &lt;-- period holding 365 days</pre>
1229 <h5>
1230 <a name="idp180499568"></a>Delimiters</h5>
1231 <p>There are four delimiters. The default values are</p>
1232 <table border="0" summary="Simple list" class="simplelist">
1233 <tr><td>"\" - separator</td></tr>
1234 <tr><td>"[" - start delimiter</td></tr>
1235 <tr><td>")" - open range end delimiter</td></tr>
1236 <tr><td>"]" - closed range end delimiter</td></tr>
1237 </table>
1238 <p>A user can provide a custom set of delimiters. Custom delimiters may contain spaces.</p>
1239 <h5>
1240 <a name="idp180503344"></a>Customization</h5>
1241 <p>The period form and delimiters can be set as construction parameters or by means of accessor functions. A custom period parser/formatter can then be used as a construction parameter to a new facet, or can be set in an existing facet via an accessor function.</p>
1242 <h5>
1243 <a name="idp180504688"></a>Period Formatter/Parser Reference</h5>
1244   The complete class reference can be found here: <code class="computeroutput"><a class="link" href="../boost/date_time/period_formatter.html" title="Class template period_formatter">Period Formatter Doxygen Reference</a></code> and here: <code class="computeroutput"><a class="link" href="../boost/date_time/period_parser.html" title="Class template period_parser">Period Parser Doxygen Reference</a></code><p>
1245     </p>
1246 <h5>
1247 <a name="idp180508240"></a>Period Formatter Construction</h5>
1248 <p>
1249     </p>
1250 <div class="informaltable"><table class="table">
1251 <colgroup>
1252 <col>
1253 <col>
1254 </colgroup>
1255 <thead><tr>
1256 <th valign="top">Syntax</th>
1257 <th>Description</th>
1258 </tr></thead>
1259 <tbody><tr>
1260 <td valign="top"><pre class="screen">period_formatter(...)
1261   Parameters:
1262     range_display_options
1263     char_type*
1264     char_type*
1265     char_type*
1266     char_type*</pre></td>
1267 <td>NOTE: All five construction parameters have default values so this constructor also doubles as the default constructor. The <code class="computeroutput">range_display_options</code> is a public type enum of the <code class="computeroutput">period_formatter</code> class. The possible choices are AS_OPEN_RANGE or AS_CLOSED_RANGE. The closed range is the default. A period has three significant points: the begining, the last, and the end. A closed range period takes the form [begin,end), where an open range period takes the form [begin,last]. The four char_type* parameters are: the period separator, the start delimiter, the open range end delimiter, and the closed range end delimiter.</td>
1268 </tr></tbody>
1269 </table></div>
1270 <p>
1271     </p>
1272 <h5>
1273 <a name="idp180516368"></a>Period Formatter Accessors</h5>
1274 <p>
1275     </p>
1276 <div class="informaltable"><table class="table">
1277 <colgroup>
1278 <col>
1279 <col>
1280 </colgroup>
1281 <thead>
1282 <tr>
1283 <th rowspan="2" valign="top">Syntax</th>
1284 <th>Description</th>
1285 </tr>
1286 <tr><th>Example</th></tr>
1287 </thead>
1288 <tbody>
1289 <tr>
1290 <td rowspan="2" valign="top"><pre class="screen">range_display_options range_option()</pre></td>
1291 <td>Returns the current setting for the range display (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</td>
1292 </tr>
1293 <tr><td><pre class="screen"></pre></td></tr>
1294 <tr>
1295 <td rowspan="2" valign="top"><pre class="screen">void range_option(...)
1296   Parameter:
1297     range_display_options</pre></td>
1298 <td>Sets the option for range display (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</td>
1299 </tr>
1300 <tr><td><pre class="screen"></pre></td></tr>
1301 <tr>
1302 <td rowspan="2" valign="top"><pre class="screen">void delimiter_strings(...)
1303   Parameters:
1304     string_type
1305     string_type
1306     string_type
1307     string_type</pre></td>
1308 <td>Set new delimiter strings in the formatter.</td>
1309 </tr>
1310 <tr><td><pre class="screen">string beg("-&gt;| ");
1311 string sep(" || ");
1312 string opn(" -&gt;|");
1313 string clo(" |&lt;-");
1314 pf.delimiter_strings(beg, sep, 
1315                      opn, clo);</pre></td></tr>
1316 <tr>
1317 <td rowspan="2" valign="top"><pre class="screen">put_period_start_delimeter(...)
1318   Return Type:
1319     OutItrT
1320   Parameter:
1321     OutItrT</pre></td>
1322 <td>Puts the start delimiter into the stream at position pointed to by OutItrT parameter.</td>
1323 </tr>
1324 <tr><td><pre class="screen"></pre></td></tr>
1325 <tr>
1326 <td rowspan="2" valign="top"><pre class="screen">put_period_sepatator(...)
1327   Return Type:
1328     OutItrT
1329   Parameter:
1330     OutItrT</pre></td>
1331 <td>Puts the separator into the stream at position pointed to by OutItrT parameter.</td>
1332 </tr>
1333 <tr><td><pre class="screen"></pre></td></tr>
1334 <tr>
1335 <td rowspan="2" valign="top"><pre class="screen">put_period_end_delimeter(...)
1336   Return Type:
1337     OutItrT
1338   Parameter:
1339     OutItrT</pre></td>
1340 <td>Puts the end delimiter into the stream at position pointed to by OutItrT parameter.</td>
1341 </tr>
1342 <tr><td><pre class="screen"></pre></td></tr>
1343 <tr>
1344 <td rowspan="2" valign="top"><pre class="screen">OutItrT put_period(...)
1345   Parameters:
1346     OutItrT
1347     ios_base
1348     char_type
1349     period_type
1350     facet_type</pre></td>
1351 <td>Puts a period into the stream using the set values for delimiters, separator, and range display. The facet parameter is used to put the date (or time) objects of the period.</td>
1352 </tr>
1353 <tr><td><pre class="screen"></pre></td></tr>
1354 </tbody>
1355 </table></div>
1356 <p>
1357   </p>
1358 <p>
1359     </p>
1360 <h5>
1361 <a name="idp180545456"></a>Period Parser Construction</h5>
1362 <p>
1363     </p>
1364 <div class="informaltable"><table class="table">
1365 <colgroup>
1366 <col>
1367 <col>
1368 </colgroup>
1369 <thead><tr>
1370 <th valign="top">Syntax</th>
1371 <th>Description</th>
1372 </tr></thead>
1373 <tbody>
1374 <tr>
1375 <td valign="top"><pre class="screen">period_parser(...)
1376   Parameters:
1377     period_range_option
1378     char_type*
1379     char_type*
1380     char_type*
1381     char_type*</pre></td>
1382 <td>NOTE: All five construction parameters have default values so this constructor also doubles as the default constructor. The <code class="computeroutput">period_range_option</code> is a public type enum of the <code class="computeroutput">period_parser</code> class. The possible choices are AS_OPEN_RANGE or AS_CLOSED_RANGE. The closed range is the default. A period has three significant points: the begining, the last, and the end. A closed range period takes the form [begin,end), where an open range period takes the form [begin,last]. The four char_type* parameters are: the period separator, the start delimiter, the open range end delimiter, and the closed range end delimiter.</td>
1383 </tr>
1384 <tr>
1385 <td valign="top"><pre class="screen">period_parser(period_parser)</pre></td>
1386 <td>Copy constructor</td>
1387 </tr>
1388 </tbody>
1389 </table></div>
1390 <p>
1391     </p>
1392 <h5>
1393 <a name="idp180555440"></a>Period Parser Accessors</h5>
1394 <p>
1395     </p>
1396 <div class="informaltable"><table class="table">
1397 <colgroup>
1398 <col>
1399 <col>
1400 </colgroup>
1401 <thead>
1402 <tr>
1403 <th rowspan="2" valign="top">Syntax</th>
1404 <th>Description</th>
1405 </tr>
1406 <tr><th>Example</th></tr>
1407 </thead>
1408 <tbody>
1409 <tr>
1410 <td rowspan="2" valign="top"><pre class="screen">period_range_option range_option()</pre></td>
1411 <td>Returns the current setting for the period range (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</td>
1412 </tr>
1413 <tr><td><pre class="screen"></pre></td></tr>
1414 <tr>
1415 <td rowspan="2" valign="top"><pre class="screen">void range_option(...)
1416   Parameter:
1417     period_range_option </pre></td>
1418 <td>Sets the option for period range (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</td>
1419 </tr>
1420 <tr><td><pre class="screen"></pre></td></tr>
1421 <tr>
1422 <td rowspan="2" valign="top"><pre class="screen">void delimiter_strings(...)
1423   Parameters:
1424     string_type
1425     string_type
1426     string_type
1427     string_type</pre></td>
1428 <td>Set new delimiter strings in the parser.</td>
1429 </tr>
1430 <tr><td><pre class="screen">string beg("-&gt;| ");
1431 string sep(" || ");
1432 string opn(" -&gt;|");
1433 string clo(" |&lt;-");
1434 pp.delimiter_strings(beg, sep, 
1435                      opn, clo);</pre></td></tr>
1436 <tr>
1437 <td rowspan="2" valign="top"><pre class="screen">collection_type delimiter_strings()</pre></td>
1438 <td>Returns the set of delimiter strings currently held in the parser.</td>
1439 </tr>
1440 <tr><td><pre class="screen"></pre></td></tr>
1441 <tr>
1442 <td rowspan="2" valign="top"><pre class="screen">period_type get_period(...)
1443   Parameters:
1444     stream_itr_type
1445     stream_itr_type
1446     ios_base
1447     period_type
1448     duration_type
1449     facet_type</pre></td>
1450 <td>Parses a period from the stream. The iterator parameters point to the begining and end of the stream. The duration_type is relevant to the period type, for example: A <code class="computeroutput">date_period</code> would use <code class="computeroutput">days</code> as a duration_type. The period will be parsed according to the formats and strings found in the facet parameter.</td>
1451 </tr>
1452 <tr><td><pre class="screen"></pre></td></tr>
1453 </tbody>
1454 </table></div>
1455 <p>
1456   </p>
1457 <p>_____________________________________________________</p>
1458 <a name="io_objects.date_generators"></a><h4>
1459 <a name="idp180580432"></a>Date Generators</h4>
1460 <p>The date_generator formatter and parser provide flexibility by allowing the user to use custom "phrase elements". These phrase elements are the "in-between" words in the date_generators. For example, in the date_generator "Second Monday of March", "Second" and "of" are the phrase elements, where "Monday" and "March" are the date elements. Customization of the date elements is done with the facet. The order of the date and phrase elements cannot be changed. When parsing, all elements of the date_generator phrase must parse correctly or an ios_base::failure exception will be thrown.</p>
1461 <h5>
1462 <a name="idp180582112"></a>Customization</h5>
1463 <p>The default "phrase_strings" are:
1464     </p>
1465 <table border="0" summary="Simple list" class="simplelist"><tr>
1466 <td>"first"</td>
1467 <td>"second"</td>
1468 <td>"third"</td>
1469 <td>"fourth"</td>
1470 <td>"fifth"</td>
1471 <td>"last"</td>
1472 <td>"before"</td>
1473 <td>"after"</td>
1474 <td>"of"</td>
1475 </tr></table>
1476 <p>
1477     A custom set of phrase_strings must maintain this order of occurance (Ex: "1st", "2nd", "3rd", "4th", "5th", "last", "prior", "past", "in").</p>
1478 <p> Examples using default phrase_strings and default facet formats for weekday &amp; month: </p>
1479 <pre class="screen">"first Tue of Mar"</pre>
1480 <p>And using custom phrase_strings: </p>
1481 <pre class="screen">"1st Tue in Mar"</pre>
1482 <p>
1483   </p>
1484 <p>The custom set of phrase elements can be set as construction parameters or through an accessor function.A custom date_generator parser/formatter can then be used as a construction parameter to a new facet, or can be set in an existing facet via an accessor function.</p>
1485 <p>IMPORTANT NOTE: Prior to 1.33, partial_date was output as "1 Jan" with a single *or* double digit number for the day. The new behavior is to *always* place a double digit number for the day - "01 Jan".</p>
1486 <h5>
1487 <a name="idp180591248"></a>Date Generator Reference</h5>
1488   The complete class references can be found here: <code class="computeroutput"><a class="link" href="../boost/date_time/date_generator_formatter.html" title="Class template date_generator_formatter">Date Generator Formatter Doxygen Reference</a></code> and here: <code class="computeroutput"><a class="link" href="../boost/date_time/date_generator_parser.html" title="Class template date_generator_parser">Date Generator Parser Doxygen Reference</a></code><p>
1489     </p>
1490 <h5>
1491 <a name="idp180594848"></a>Date Generator Formatter Construction</h5>
1492 <p>
1493     </p>
1494 <div class="informaltable"><table class="table">
1495 <colgroup>
1496 <col>
1497 <col>
1498 </colgroup>
1499 <thead><tr>
1500 <th valign="top">Syntax</th>
1501 <th>Description</th>
1502 </tr></thead>
1503 <tbody>
1504 <tr>
1505 <td valign="top"><pre class="screen">date_generator_formatter()</pre></td>
1506 <td>Uses the default date generator elements.</td>
1507 </tr>
1508 <tr>
1509 <td valign="top"><pre class="screen">date_generator_formatter(...)
1510   Parameters:
1511     string_type first_element
1512     string_type second_element
1513     string_type third_element
1514     string_type fourth_element
1515     string_type fifth_element
1516     string_type last_element
1517     string_type before_element
1518     string_type after_element
1519     string_type of_element</pre></td>
1520 <td>Constructs a date_generator_formatter using the given element strings.</td>
1521 </tr>
1522 </tbody>
1523 </table></div>
1524 <p>
1525     </p>
1526 <h5>
1527 <a name="idp180603136"></a>Date Generator Formatter Accessors</h5>
1528 <p>
1529     </p>
1530 <div class="informaltable"><table class="table">
1531 <colgroup>
1532 <col>
1533 <col>
1534 </colgroup>
1535 <thead>
1536 <tr>
1537 <th rowspan="2" valign="top">Syntax</th>
1538 <th>Description</th>
1539 </tr>
1540 <tr><th>Example</th></tr>
1541 </thead>
1542 <tbody>
1543 <tr>
1544 <td rowspan="2" valign="top"><pre class="screen">void elements(...)
1545   Parameters:
1546     collection_type
1547     phrase_elements</pre></td>
1548 <td>Replace the current phrase elements with a collection of new ones. The <code class="computeroutput">phrase_elements</code> parameter is an enum that indicates what the first element in the new collection is (defaults to first).</td>
1549 </tr>
1550 <tr><td><pre class="screen">// col is a collection holding 
1551 // "final", "prior", "following",
1552 // and "in"
1553 typedef date_generator_formatter dgf;                                  
1554 dgf formatter();
1555 formatter.elements(col, dgf::last);
1556 // complete elements in dgf are now: 
1557 "first", "second", "third", 
1558 "fourth", "fifth", "final", 
1559 "prior", "following", and "in"</pre></td></tr>
1560 <tr>
1561 <td rowspan="2" valign="top"><pre class="screen">put_partial_date(...)
1562   Return Type:
1563     facet_type::OutItrT
1564   Parameters:
1565     OutItrT next
1566     ios_base
1567     char_type fill
1568     partial_date
1569     facet_type</pre></td>
1570 <td>A put function for partial_date. This is a templated function that takes a facet_type as a parameter.</td>
1571 </tr>
1572 <tr><td>Put a partial_date =&gt; "dd Month".</td></tr>
1573 <tr>
1574 <td rowspan="2" valign="top"><pre class="screen">put_nth_kday(...)
1575   Return Type:
1576     facet_type::OutItrT
1577   Parameters:
1578     OutItrT next
1579     ios_base
1580     char_type fill
1581     nth_kday_type
1582     facet_type</pre></td>
1583 <td>A put function for nth_kday_type. This is a templated function that takes a facet_type as a parameter.</td>
1584 </tr>
1585 <tr><td>Put an nth_day_of_the_week_in_month =&gt; "nth weekday of month".</td></tr>
1586 <tr>
1587 <td rowspan="2" valign="top"><pre class="screen">put_first_kday(...)
1588   Return Type:
1589     facet_type::OutItrT
1590   Parameters:
1591     OutItrT next
1592     ios_base
1593     char_type fill
1594     first_kday_type
1595     facet_type</pre></td>
1596 <td>A put function for first_kday_type. This is a templated function that takes a facet_type as a parameter.</td>
1597 </tr>
1598 <tr><td>Put a first_day_of_the_week_in_month =&gt; "first weekday of month".</td></tr>
1599 <tr>
1600 <td rowspan="2" valign="top"><pre class="screen">put_last_kday(...)
1601   Return Type:
1602     facet_type::OutItrT
1603   Parameters:
1604     OutItrT next
1605     ios_base
1606     char_type fill
1607     last_kday_type
1608     facet_type</pre></td>
1609 <td>A put function for last_kday_type. This is a templated function that takes a facet_type as a parameter.</td>
1610 </tr>
1611 <tr><td>Put a last_day_of_the_week_in_month =&gt; "last weekday of month".</td></tr>
1612 <tr>
1613 <td rowspan="2" valign="top"><pre class="screen">put_kday_before(...)
1614   Return Type:
1615     facet_type::OutItrT
1616   Parameters:
1617     OutItrT next
1618     ios_base
1619     char_type fill
1620     kday_before_type
1621     facet_type</pre></td>
1622 <td>A put function for kday_before_type. This is a templated function that takes a facet_type as a parameter.</td>
1623 </tr>
1624 <tr><td>Put a first_day_of_the_week_before =&gt; "weekday before"</td></tr>
1625 <tr>
1626 <td rowspan="2" valign="top"><pre class="screen">put_kday_after(...)
1627   Return Type:
1628     facet_type::OutItrT
1629   Parameters:
1630     OutItrT next
1631     ios_base
1632     char_type fill
1633     kday_after_type
1634     facet_type</pre></td>
1635 <td>A put function for kday_after_type. This is a templated function that takes a facet_type as a parameter.</td>
1636 </tr>
1637 <tr><td>Put a first_day_of_the_week_after =&gt; "weekday after".</td></tr>
1638 </tbody>
1639 </table></div>
1640 <p>
1641   </p>
1642 <p>
1643     </p>
1644 <h5>
1645 <a name="idp180632400"></a>Date Generator Parser Construction</h5>
1646 <p>
1647     </p>
1648 <div class="informaltable"><table class="table">
1649 <colgroup>
1650 <col>
1651 <col>
1652 </colgroup>
1653 <thead><tr>
1654 <th valign="top">Syntax</th>
1655 <th>Description</th>
1656 </tr></thead>
1657 <tbody>
1658 <tr>
1659 <td valign="top"><pre class="screen">date_generator_parser()</pre></td>
1660 <td>Uses the default date generator elements.</td>
1661 </tr>
1662 <tr>
1663 <td valign="top"><pre class="screen">date_generator_parser(...)
1664   Parameter:
1665     date_generator_parser</pre></td>
1666 <td>Copy Constructor</td>
1667 </tr>
1668 <tr>
1669 <td valign="top"><pre class="screen">date_generator_parser(...)
1670   Parameters:
1671     string_type first_element
1672     string_type second_element
1673     string_type third_element
1674     string_type fourth_element
1675     string_type fifth_element
1676     string_type last_element
1677     string_type before_element
1678     string_type after_element
1679     string_type of_element</pre></td>
1680 <td>Constructs a date_generator_parser using the given element strings.</td>
1681 </tr>
1682 </tbody>
1683 </table></div>
1684 <p>
1685     </p>
1686 <h5>
1687 <a name="idp180642560"></a>Date Generator Parser Accessors</h5>
1688 <p>
1689     </p>
1690 <div class="informaltable"><table class="table">
1691 <colgroup>
1692 <col>
1693 <col>
1694 </colgroup>
1695 <thead>
1696 <tr>
1697 <th rowspan="2" valign="top">Syntax</th>
1698 <th>Description</th>
1699 </tr>
1700 <tr><th>Example</th></tr>
1701 </thead>
1702 <tbody>
1703 <tr>
1704 <td rowspan="2" valign="top"><pre class="screen">void element_strings(...)
1705   Parameter:
1706     collection_type</pre></td>
1707 <td>Replace the set of date generator element string with a new set.</td>
1708 </tr>
1709 <tr><td><pre class="screen"></pre></td></tr>
1710 <tr>
1711 <td rowspan="2" valign="top"><pre class="screen">void element_strings(...)
1712   Parameters:
1713     string_type first
1714     string_type second
1715     string_type third
1716     string_type fourth
1717     string_type fifth
1718     string_type last
1719     string_type before
1720     string_type after
1721     string_type of</pre></td>
1722 <td>Replace the set of date generator elements with new values.</td>
1723 </tr>
1724 <tr><td><pre class="screen"></pre></td></tr>
1725 <tr>
1726 <td rowspan="2" valign="top"><pre class="screen">get_partial_date_type(...)
1727   Return Type:
1728     facet_type::partial_date_type
1729   Parameters:
1730     stream_itr_type next
1731     stream_itr_type str_end
1732     ios_base
1733     facet_type</pre></td>
1734 <td>A templated function that parses a date_generator from the stream.</td>
1735 </tr>
1736 <tr><td>Parses a partial_date =&gt; "dd Month".</td></tr>
1737 <tr>
1738 <td rowspan="2" valign="top"><pre class="screen">get_nth_kday_type(...)
1739   Return Type:
1740     facet_type::nth_kday_type
1741   Parameters:
1742     stream_itr_type next
1743     stream_itr_type str_end
1744     ios_base
1745     facet_type</pre></td>
1746 <td>A templated function that parses a date_generator from the stream.</td>
1747 </tr>
1748 <tr><td>Parses an nth_day_of_the_week_in_month =&gt; "nth weekday of month".</td></tr>
1749 <tr>
1750 <td rowspan="2" valign="top"><pre class="screen">get_first_kday_type(...)
1751   Return Type:
1752     facet_type::firat_kday_type
1753   Parameters:
1754     stream_itr_type next
1755     stream_itr_type str_end
1756     ios_base
1757     facet_type</pre></td>
1758 <td>A templated function that parses a date_generator from the stream.</td>
1759 </tr>
1760 <tr><td>Parses a first_day_of_the_week_in_month =&gt; "first weekday of month".</td></tr>
1761 <tr>
1762 <td rowspan="2" valign="top"><pre class="screen">get_last_kday_type(...)
1763   Return Type:
1764     facet_type::last_kday_type
1765   Parameters:
1766     stream_itr_type next
1767     stream_itr_type str_end
1768     ios_base
1769     facet_type</pre></td>
1770 <td>A templated function that parses a date_generator from the stream.</td>
1771 </tr>
1772 <tr><td>Parses a last_day_of_the_week_in_month =&gt; "last weekday of month".</td></tr>
1773 <tr>
1774 <td rowspan="2" valign="top"><pre class="screen">get_kday_before_type(...)
1775   Return Type:
1776     facet_type::kday_before_type
1777   Parameters:
1778     stream_itr_type next
1779     stream_itr_type str_end
1780     ios_base
1781     facet_type</pre></td>
1782 <td>A templated function that parses a date_generator from the stream.</td>
1783 </tr>
1784 <tr><td>Parses a first_day_of_the_week_before =&gt; "weekday before"</td></tr>
1785 <tr>
1786 <td rowspan="2" valign="top"><pre class="screen">get_kday_after_type(...)
1787   Return Type:
1788     facet_type::kday_after_type
1789   Parameters:
1790     stream_itr_type next
1791     stream_itr_type str_end
1792     ios_base
1793     facet_type</pre></td>
1794 <td>A templated function that parses a date_generator from the stream.</td>
1795 </tr>
1796 <tr><td>Parses a first_day_of_the_week_after =&gt; "weekday after".</td></tr>
1797 </tbody>
1798 </table></div>
1799 <p>
1800   </p>
1801 <p>_____________________________________________________</p>
1802 <a name="io_objects.special_values"></a><h4>
1803 <a name="idp180674672"></a>Special Values</h4>
1804 <p>The date_time library uses five special_values. They are:
1805     </p>
1806 <table border="0" summary="Simple list" class="simplelist"><tr>
1807 <td>not_a_date_time</td>
1808 <td>neg_infin</td>
1809 <td>pos_infin</td>
1810 <td>min_date_time</td>
1811 <td>max_date_time</td>
1812 </tr></table>
1813 <p>
1814   </p>
1815 <p>The default set of strings used to represent these types are: "not-a-date-time", "-infinity", "+infinity", "minimum-date-time", "maximum-date-time". When output, the min_date-time and max_date_time appear as normal date/time representations: "1400-Jan-01" and "9999-Dec-31" repectively.</p>
1816 <h5>
1817 <a name="idp180679488"></a>Customization</h5>
1818 <p>The special values parser/formatter allows the user to set custom strings for these special values. These strings can be set as construction parameters to a new facet, or can be set in an existing facet via an accessor function.</p>
1819 <h5>
1820 <a name="idp180680800"></a>Special Values Formatter/Parser Reference</h5>
1821   The complete class references can be found here: <code class="computeroutput"><a class="link" href="../boost/date_time/special_values_formatter.html" title="Class template special_values_formatter">Special Values Formatter Doxygen Reference</a></code> and here: <code class="computeroutput"><a class="link" href="../boost/date_time/special_values_parser.html" title="Class template special_values_parser">Special Values Parser Doxygen Reference</a></code><p>
1822     </p>
1823 <h5>
1824 <a name="idp180684368"></a>Special Values Formatter Constructor</h5>
1825 <p>
1826     </p>
1827 <div class="informaltable"><table class="table">
1828 <colgroup>
1829 <col>
1830 <col>
1831 </colgroup>
1832 <thead><tr>
1833 <th valign="top">Syntax</th>
1834 <th>Description</th>
1835 </tr></thead>
1836 <tbody>
1837 <tr>
1838 <td valign="top"><pre class="screen">special_values_formatter()</pre></td>
1839 <td>Constructor uses defaults for special value strings.</td>
1840 </tr>
1841 <tr>
1842 <td valign="top"><pre class="screen">special_values_formatter(...)
1843   Parameters:
1844     collection_type::iterator
1845     collection_type::iterator</pre></td>
1846 <td>Constructs using values in collection. NOTE: Only the first three strings of the collection will be used. Strings for minimum_date_time and maximum_date_time are ignored as those special values are output as normal dates/times.</td>
1847 </tr>
1848 <tr>
1849 <td valign="top"><pre class="screen">special_values_formatter(...)
1850   Parameters:
1851     char_type*
1852     char_type*</pre></td>
1853 <td>Constructs special values formatter from an array of strings.</td>
1854 </tr>
1855 </tbody>
1856 </table></div>
1857 <p>
1858   </p>
1859 <p>
1860     </p>
1861 <h5>
1862 <a name="idp180694944"></a>Special Values Formatter Accessors</h5>
1863 <p>
1864     </p>
1865 <div class="informaltable"><table class="table">
1866 <colgroup>
1867 <col>
1868 <col>
1869 </colgroup>
1870 <thead>
1871 <tr>
1872 <th rowspan="2" valign="top">Syntax</th>
1873 <th>Description</th>
1874 </tr>
1875 <tr><th>Example</th></tr>
1876 </thead>
1877 <tbody>
1878 <tr>
1879 <td rowspan="2" valign="top"><pre class="screen">OutItrT put_special(...)
1880   Parameters:
1881     OutItrT next
1882     special_values value</pre></td>
1883 <td>Puts the given special value into the stream.</td>
1884 </tr>
1885 <tr><td><pre class="screen">date d1(not_a_date_time);
1886 date d2(minimum_date_time);
1887 special_values_formatter formatter;
1888 formatter.put_special(itr, d1); 
1889 // Puts: "not-a-date-time"
1890 formatter.put_special(itr, d2); 
1891 // Puts: "1400-Jan-01"</pre></td></tr>
1892 </tbody>
1893 </table></div>
1894 <p>
1895   </p>
1896 <p>
1897     </p>
1898 <h5>
1899 <a name="idp180704128"></a>Special Values Parser Constructor</h5>
1900 <p>
1901     </p>
1902 <div class="informaltable"><table class="table">
1903 <colgroup>
1904 <col>
1905 <col>
1906 </colgroup>
1907 <thead><tr>
1908 <th valign="top">Syntax</th>
1909 <th>Description</th>
1910 </tr></thead>
1911 <tbody>
1912 <tr>
1913 <td valign="top"><pre class="screen">special_values_parser()</pre></td>
1914 <td>&#160;</td>
1915 </tr>
1916 <tr>
1917 <td valign="top"><pre class="screen">special_values_parser(...)
1918   Parameters:
1919     collection_type::iterator
1920     collection_type::iterator</pre></td>
1921 <td>Constructs a special values parser using the strings in the collection.</td>
1922 </tr>
1923 <tr>
1924 <td valign="top"><pre class="screen">special_values_parser(...)
1925   Parameter:
1926     scpecial_values_parser</pre></td>
1927 <td>Copy constructor.</td>
1928 </tr>
1929 <tr>
1930 <td valign="top"><pre class="screen">special_values_parser(...)
1931   Parameters:
1932     string_type nadt_str
1933     string_type neg_inf_str
1934     string_type pos_inf_str
1935     string_type min_dt_str
1936     string_type max_dt_str</pre></td>
1937 <td>Constructs a special values parser using the supplied strings.</td>
1938 </tr>
1939 </tbody>
1940 </table></div>
1941 <p>
1942   </p>
1943 <p>
1944     </p>
1945 <h5>
1946 <a name="idp180716336"></a>Special Values Parser Accessors</h5>
1947 <p>
1948     </p>
1949 <div class="informaltable"><table class="table">
1950 <colgroup>
1951 <col>
1952 <col>
1953 </colgroup>
1954 <thead>
1955 <tr>
1956 <th rowspan="2" valign="top">Syntax</th>
1957 <th>Description</th>
1958 </tr>
1959 <tr><th>Example</th></tr>
1960 </thead>
1961 <tbody>
1962 <tr>
1963 <td rowspan="2" valign="top"><pre class="screen">void sv_strings(...)
1964   Parameters:
1965     string_type nadt_str
1966     string_type neg_inf_str
1967     string_type pos_inf_str
1968     string_type min_dt_str
1969     string_type max_dt_str</pre></td>
1970 <td>Replace the set of special value strings with the given ones.</td>
1971 </tr>
1972 <tr><td><pre class="screen"></pre></td></tr>
1973 <tr>
1974 <td rowspan="2" valign="top"><pre class="screen">bool match(...)
1975   Parameters:
1976     stream_itr_type beg
1977     stream_itr_type end
1978     match_results</pre></td>
1979 <td>Returns true if parse was successful. Upon a successful parse, <code class="computeroutput">mr.current_match</code> will be set an int values corresponding to the equivalent special_value.</td>
1980 </tr>
1981 <tr><td><pre class="screen">// stream holds "maximum_date_time"
1982 typedef special_values_parser svp;
1983 svp parser;
1984 svp::match_results mr;
1985 if(parser.match(itr, str_end, mr)) {
1986   d = date(static_cast&lt;special_values&gt;(
1987            mr.match_results))
1988 } else {
1989   // error, failed parse
1990 }
1991 // d == "9999-Dec-31"</pre></td></tr>
1992 </tbody>
1993 </table></div>
1994 <p>
1995   </p>
1996 <p>_____________________________________________________</p>
1997 <a name="io_objects.format_date_parser"></a><h4>
1998 <a name="idp180730704"></a>Format Date Parser</h4>
1999 <p>The format date parser is the object that holds the strings for months and weekday names, as well as their abbreviations. Custom sets of strings can be set at construction time, or, the strings in an existing format_date_parser can be replaced through accessor functions. Both the constructor and the accessor functions take a vector of strings as their arguments.</p>
2000 <h5>
2001 <a name="idp180732160"></a>Format Date Parser Reference</h5>
2002   The complete class reference can be found here: <code class="computeroutput"><a class="link" href="../boost/date_time/format_date_parser.html" title="Class template format_date_parser">Doxygen Reference</a></code><p>
2003     </p>
2004 <h5>
2005 <a name="idp180734416"></a>Format Date Parser Constructor</h5>
2006 <p>
2007     </p>
2008 <div class="informaltable"><table class="table">
2009 <colgroup>
2010 <col>
2011 <col>
2012 </colgroup>
2013 <thead><tr>
2014 <th valign="top">Syntax</th>
2015 <th>Description</th>
2016 </tr></thead>
2017 <tbody>
2018 <tr>
2019 <td valign="top"><pre class="screen">format_date_parser(...)
2020                 Parameters:
2021                 string_type format
2022                 std::locale</pre></td>
2023 <td>Creates a parser that uses the given format for parsing dates (in those functions where there is no format parameter). The names and abbreviations used are extracted from the given locale.</td>
2024 </tr>
2025 <tr>
2026 <td valign="top"><pre class="screen">format_date_parser(...)
2027   Parameters:
2028     string_type format
2029     input_collection_type
2030     input_collection_type
2031     input_collection_type
2032     input_collection_type</pre></td>
2033 <td>Creates a parser from using the given components. The input_collection_type parameters are for: short month names, long month names, short weekday names, and long weekday names (in that order). These collections must contain values for every month and every weekday (begining with January and Sunday).</td>
2034 </tr>
2035 <tr>
2036 <td valign="top"><pre class="screen">format_date_parser(...)
2037   Parameters:
2038     format_date_parser</pre></td>
2039 <td>Copy Constructor</td>
2040 </tr>
2041 </tbody>
2042 </table></div>
2043 <p>
2044   </p>
2045 <p>
2046     </p>
2047 <h5>
2048 <a name="idp180745248"></a>Format Date Parser Accessors</h5>
2049 <p>
2050     </p>
2051 <div class="informaltable"><table class="table">
2052 <colgroup>
2053 <col>
2054 <col>
2055 </colgroup>
2056 <thead>
2057 <tr>
2058 <th rowspan="2" valign="top">Syntax</th>
2059 <th>Description</th>
2060 </tr>
2061 <tr><th>Example</th></tr>
2062 </thead>
2063 <tbody>
2064 <tr>
2065 <td rowspan="2" valign="top"><pre class="screen">string_type format()</pre></td>
2066 <td>Returns the format that will be used when parsing dates in those functions where there is no format parameter.</td>
2067 </tr>
2068 <tr><td><pre class="screen"></pre></td></tr>
2069 <tr>
2070 <td rowspan="2" valign="top"><pre class="screen">void format(string_type)</pre></td>
2071 <td>Sets the format that will be used when parsing dates in those functions where there is no format parameter.</td>
2072 </tr>
2073 <tr><td><pre class="screen"></pre></td></tr>
2074 <tr>
2075 <td rowspan="2" valign="top"><pre class="screen">void short_month_names(...)
2076   Parameter:
2077     input_collection_type names</pre></td>
2078 <td>Replace the short month names used by the parser. The collection must contain values for each month, starting with January.</td>
2079 </tr>
2080 <tr><td><pre class="screen"></pre></td></tr>
2081 <tr>
2082 <td rowspan="2" valign="top"><pre class="screen">void long_month_names(...)
2083   Parameter:
2084     input_collection_type names</pre></td>
2085 <td>Replace the long month names used by the parser. The collection must contain values for each month, starting with January.</td>
2086 </tr>
2087 <tr><td><pre class="screen"></pre></td></tr>
2088 <tr>
2089 <td rowspan="2" valign="top"><pre class="screen">void short_weekday_names(...)
2090   Parameter:
2091     input_collection_type names</pre></td>
2092 <td>Replace the short weekday names used by the parser. The collection must contain values for each weekday, starting with Sunday.</td>
2093 </tr>
2094 <tr><td><pre class="screen"></pre></td></tr>
2095 <tr>
2096 <td rowspan="2" valign="top"><pre class="screen">void long_weekday_names(...)
2097   Parameter:
2098     input_collection_type names</pre></td>
2099 <td>Replace the long weekday names used by the parser. The collection must contain values for each weekday, starting with Sunday.</td>
2100 </tr>
2101 <tr><td><pre class="screen"></pre></td></tr>
2102 <tr>
2103 <td rowspan="2" valign="top"><pre class="screen">date_type parse_date(...)
2104   Parameters:
2105     string_type input
2106     string_type format 
2107     special_values_parser</pre></td>
2108 <td>Parse a date from the given input using the given format.</td>
2109 </tr>
2110 <tr><td><pre class="screen">string inp("2005-Apr-15");
2111 string format("%Y-%b-%d");
2112 date d;
2113 d = parser.parse_date(inp, 
2114                       format,
2115                       svp);
2116 // d == 2005-Apr-15</pre></td></tr>
2117 <tr>
2118 <td rowspan="2" valign="top"><pre class="screen">date_type parse_date(...)
2119   Parameters:
2120     istreambuf_iterator input
2121     istreambuf_iterator str_end
2122     special_values_parser</pre></td>
2123 <td>Parse a date from stream using the parser's format.</td>
2124 </tr>
2125 <tr><td><pre class="screen"></pre></td></tr>
2126 <tr>
2127 <td rowspan="2" valign="top"><pre class="screen">date_type parse_date(...)
2128   Parameters:
2129     istreambuf_iterator input
2130     istreambuf_iterator str_end
2131     string_type format
2132     special_values_parser</pre></td>
2133 <td>Parse a date from stream using the given format.</td>
2134 </tr>
2135 <tr><td><pre class="screen">// stream holds "2005-04-15"
2136 string format("%Y-%m-%d");
2137 date d;
2138 d = parser.parse_date(itr, 
2139                       str_end, 
2140                       format,
2141                       svp);
2142 // d == 2005-Apr-15</pre></td></tr>
2143 <tr>
2144 <td rowspan="2" valign="top"><pre class="screen">month_type parse_month(...)
2145   Parameters:
2146     istreambuf_iterator input
2147     istreambuf_iterator str_end
2148     string_type format</pre></td>
2149 <td>Parses a month from stream using given format. Throws bad_month if unable to parse.</td>
2150 </tr>
2151 <tr><td><pre class="screen">// stream holds "March"
2152 string format("%B");
2153 greg_month m;
2154 m = parser.parse_month(itr, 
2155                        str_end, 
2156                        format);
2157 // m == March</pre></td></tr>
2158 <tr>
2159 <td rowspan="2" valign="top"><pre class="screen">day_type parse_day_of_month(...)
2160   Parameters:
2161     istreambuf_iterator input
2162     istreambuf_iterator str_end</pre></td>
2163 <td>Parses a day_of_month from stream. The day must appear as a two digit number (01-31), or a bad_day_of_month will be thrown.</td>
2164 </tr>
2165 <tr><td><pre class="screen">// stream holds "01"
2166 greg_day d;
2167 d = parser.parse_day_of_month(itr, 
2168                        str_end);
2169 // d == 1st</pre></td></tr>
2170 <tr>
2171 <td rowspan="2" valign="top"><pre class="screen">day_type parse_var_day_of_month(...)
2172   Parameters:
2173     istreambuf_iterator input
2174     istreambuf_iterator str_end</pre></td>
2175 <td>Parses a day_of_month from stream. The day must appear as a one or two digit number (1-31), or a bad_day_of_month will be thrown.</td>
2176 </tr>
2177 <tr><td><pre class="screen">// stream holds "1"
2178 greg_day d;
2179 d = parser.parse_var_day_of_month(itr, 
2180                        str_end);
2181 // d == 1st</pre></td></tr>
2182 <tr>
2183 <td rowspan="2" valign="top"><pre class="screen">day_of_week_type parse_weekday(...)
2184   Parameters:
2185     istreambuf_iterator input
2186     istreambuf_iterator str_end
2187     string_type format</pre></td>
2188 <td>Parse a weekday from stream according to the given format. Throws a bad_weekday if unable to parse.</td>
2189 </tr>
2190 <tr><td><pre class="screen">// stream holds "Tue"
2191 string format("%a");
2192 greg_weekday wd;
2193 wd = parser.parse_weekday(itr, 
2194                           str_end, 
2195                           format);
2196 // wd == Tuesday</pre></td></tr>
2197 <tr>
2198 <td rowspan="2" valign="top"><pre class="screen">year_type parse_year(...)
2199   Parameters:
2200     istreambuf_iterator input
2201     istreambuf_iterator str_end
2202     string_type format</pre></td>
2203 <td>Parse a year from stream according to given format. Throws bad year if unable to parse.</td>
2204 </tr>
2205 <tr><td><pre class="screen">// stream holds "98"
2206 string format("%y");
2207 greg_year y;
2208 y = parser.parse_year(itr, 
2209                       str_end, 
2210                       format);
2211 // y == 1998</pre></td></tr>
2212 </tbody>
2213 </table></div>
2214 <p>
2215   </p>
2216 </div>
2217 <div class="section">
2218 <div class="titlepage"><div><div><h3 class="title">
2219 <a name="date_time.io_tutorial"></a>Date Time IO Tutorial</h3></div></div></div>
2220 <h3>
2221 <a name="idp180800128"></a>Date Time IO Tutorial</h3>
2222 <a class="link" href="date_time_io.html#basic_use">Basic Use</a> |
2223   <a class="link" href="date_time_io.html#format_strings">Format Strings</a> |
2224   <a class="link" href="date_time_io.html#content_strings">Content Strings</a> |
2225   <a class="link" href="date_time_io.html#tut_sv">Special Values</a> |
2226   <a class="link" href="date_time_io.html#tut_dper">Date/Time Periods</a> |
2227   <a class="link" href="date_time_io.html#tut_dgen">Date Generators</a><a name="basic_use"></a><h5>
2228 <a name="idp180807328"></a>Basic Use</h5>
2229 <p>Facets are automatically imbued when operators '&gt;&gt;' and '&lt;&lt;' are called. The list of date_time objects that can be streamed are:</p>
2230 <h6>
2231 <a name="idp180808720"></a>Gregorian</h6>
2232 <p>
2233     <code class="computeroutput">date</code>, 
2234     <code class="computeroutput">days</code>, 
2235     <code class="computeroutput">date_period</code>, 
2236     <code class="computeroutput">greg_month</code>, 
2237     <code class="computeroutput">greg_weekday</code>, 
2238     <code class="computeroutput">greg_year</code>, 
2239     <code class="computeroutput">partial_date</code>, 
2240     <code class="computeroutput">nth_day_of_the_week_in_month</code>, 
2241     <code class="computeroutput">first_day_of_the_week_in_month</code>, 
2242     <code class="computeroutput">last_day_of_the_week_in_month</code>, 
2243     <code class="computeroutput">first_day_of_the_week_after</code>, 
2244     <code class="computeroutput">first_day_of_the_week_before</code>
2245   </p>
2246 <h6>
2247 <a name="idp180818480"></a>Posix_time</h6>
2248 <p>
2249     <code class="computeroutput">ptime</code>, 
2250     <code class="computeroutput">time_period</code>, 
2251     <code class="computeroutput">time_duration</code>
2252   </p>
2253 <h6>
2254 <a name="idp180821680"></a>Local_time</h6>
2255 <p>
2256     <code class="computeroutput">local_date_time</code>
2257   </p>
2258 <p>
2259     The following example is of the basic use of the new IO code, utilizing all the defaults. (this example can be found in the <code class="computeroutput">libs/date_time/examples/tutorial</code> directory)
2260   </p>
2261 <pre class="programlisting">
2262     
2263   date d(2004, Feb, 29);
2264   time_duration td(12,34,56,789);
2265   stringstream ss;
2266   ss &lt;&lt; d &lt;&lt; ' ' &lt;&lt; td;
2267   ptime pt(not_a_date_time);
2268   cout &lt;&lt; pt &lt;&lt; endl; // "not-a-date-time"
2269   ss &gt;&gt; pt;
2270   cout &lt;&lt; pt &lt;&lt; endl; // "2004-Feb-29 12:34:56.000789"
2271   ss.str("");
2272   ss &lt;&lt; pt &lt;&lt; " EDT-05EDT,M4.1.0,M10.5.0";
2273   local_date_time ldt(not_a_date_time);
2274   ss &gt;&gt; ldt;
2275   cout &lt;&lt; ldt &lt;&lt; endl; // "2004-Feb-29 12:34:56.000789 EDT"
2276     
2277   </pre>
2278 <p>This example used the default settings for the input and output facets. The default formats are such that interoperability like that shown in the example is possible. NOTE: Input streaming of local_date_time can only be done with a <a class="link" href="local_time.html#date_time.local_time.posix_time_zone" title="Posix Time Zone">posix time zone string</a>. The default output format uses a time zone abbreviation. The format can be changed so out and in match (as we will see later in this tutorial).</p>
2279 <a name="format_strings"></a><h5>
2280 <a name="idp180828208"></a>Format Strings</h5>
2281 <p>The format strings control the order, type, and style of the date/time elements used. The facets provide some predefined formats (iso_format_specifier, iso_format_extended_specifier, and default_date_format) but the user can easily create their own.</p>
2282   (continued from previous example)
2283   <pre class="programlisting">
2284     
2285   local_time_facet* output_facet = new local_time_facet();
2286   local_time_input_facet* input_facet = new local_time_input_facet();
2287   ss.imbue(locale(locale::classic(), output_facet));
2288   ss.imbue(locale(ss.getloc(), input_facet));
2289   
2290   output_facet-&gt;format("%a %b %d, %H:%M %z");
2291   ss.str("");
2292   ss &lt;&lt; ldt;
2293   cout &lt;&lt; ss.str() &lt;&lt; endl; // "Sun Feb 29, 12:34 EDT"
2294
2295   output_facet-&gt;format(local_time_facet::iso_time_format_specifier);
2296   ss.str("");
2297   ss &lt;&lt; ldt;
2298   cout &lt;&lt; ss.str() &lt;&lt; endl; // "20040229T123456.000789-0500"
2299  
2300   output_facet-&gt;format(local_time_facet::iso_time_format_extended_specifier);
2301   ss.str("");
2302   ss &lt;&lt; ldt;
2303   cout &lt;&lt; ss.str() &lt;&lt; endl; // "2004-02-29 12:34:56.000789-05:00"
2304     
2305   </pre>
2306 <p>Format strings are not limited to date/time elements. Extra verbiage can be placed in a format string. NOTE: When extra verbiage is present in an input format, the data being input must also contain the exact verbiage.</p>
2307   (continued from previous example)
2308   <pre class="programlisting">
2309     
2310   // extra words in format
2311   string my_format("The extended ordinal time %Y-%jT%H:%M can also be \
2312   represented as %A %B %d, %Y");
2313   output_facet-&gt;format(my_format.c_str());
2314   input_facet-&gt;format(my_format.c_str());
2315   ss.str("");
2316   ss &lt;&lt; ldt;
2317   cout &lt;&lt; ss.str() &lt;&lt; endl;
2318
2319   // matching extra words in input 
2320   ss.str("The extended ordinal time 2005-128T12:15 can also be \
2321   represented as Sunday May 08, 2005");
2322   ss &gt;&gt; ldt;
2323   cout &lt;&lt; ldt &lt;&lt; endl;
2324     
2325   </pre>
2326 <a name="content_strings"></a><h5>
2327 <a name="idp180834256"></a>Content Strings</h5>
2328 <p>So far we've shown how a user can achieve a great deal of customization with very little effort by using formats. Further customization can be achieved through user defined elements (ie strings). The elements that can be customized are: Special value names, month names, month abbreviations, weekday names, weekday abbreviations, delimiters of the date/time periods, and the phrase elements of the date_generators.</p>
2329 <p>The default values for these are as follows:</p>
2330 <h6>
2331 <a name="idp180836176"></a>Special values</h6>
2332 <p>
2333     <code class="computeroutput">not-a-date-time</code>, 
2334     <code class="computeroutput">-infinity</code>, 
2335     <code class="computeroutput">+infinity</code>, 
2336     <code class="computeroutput">minimum-date-time</code>, 
2337     <code class="computeroutput">maximum-date-time</code>
2338   </p>
2339 <h6>
2340 <a name="idp180840816"></a>Months</h6>
2341 <p>
2342     <code class="computeroutput">English calendar and three letter abbreviations</code>
2343   </p>
2344 <h6>
2345 <a name="idp180842608"></a>Weekdays</h6>
2346 <p>
2347     <code class="computeroutput">English calendar and three letter abbreviations</code>
2348   </p>
2349 <h6>
2350 <a name="idp180844400"></a>Date generator phrase elements</h6>
2351 <p>
2352     <code class="computeroutput">first</code>, 
2353     <code class="computeroutput">second</code>, 
2354     <code class="computeroutput">third</code>, 
2355     <code class="computeroutput">fourth</code>, 
2356     <code class="computeroutput">fifth</code>, 
2357     <code class="computeroutput">last</code>, 
2358     <code class="computeroutput">before</code>, 
2359     <code class="computeroutput">after</code>, 
2360     <code class="computeroutput">of</code>
2361   </p>
2362 <p>NOTE: We've shown earlier that the components of a date/time representation can be re-ordered via the format string. This is not the case with date_generators. The elements themselves can be customized but their order cannot be changed.</p>
2363 <h5>
2364 <a name="idp180852544"></a>Content Strings</h5>
2365 <p>To illustrate the customization possibilities we will use custom strings for months and weekdays (we will only use long names, is all lowercase, for this example).</p>
2366   (continued from previous example)
2367   <pre class="programlisting">
2368     
2369   // set up the collections of custom strings.
2370   // only the full names are altered for the sake of brevity
2371   string month_names[12] = { "january", "february", "march", 
2372                              "april", "may", "june", 
2373                              "july", "august", "september", 
2374                              "october", "november", "december" };
2375   vector&lt;string&gt; long_months(&amp;month_names[0], &amp;month_names[12]);
2376   string day_names[7] = { "sunday", "monday", "tuesday", "wednesday", 
2377                           "thursday", "friday", "saturday" };
2378   vector&lt;string&gt; long_days(&amp;day_names[0], &amp;day_names[7]);
2379   
2380   //  create date_facet and date_input_facet using all defaults
2381   date_facet* date_output = new date_facet();
2382   date_input_facet* date_input = new date_input_facet();
2383   ss.imbue(locale(ss.getloc(), date_output)); 
2384   ss.imbue(locale(ss.getloc(), date_input));
2385
2386   // replace names in the output facet
2387   date_output-&gt;long_month_names(long_months);
2388   date_output-&gt;long_weekday_names(long_days);
2389   
2390   // replace names in the input facet
2391   date_input-&gt;long_month_names(long_months);
2392   date_input-&gt;long_weekday_names(long_days);
2393   
2394   // customize month, weekday and date formats
2395   date_output-&gt;format("%Y-%B-%d");
2396   date_input-&gt;format("%Y-%B-%d");
2397   date_output-&gt;month_format("%B"); // full name
2398   date_input-&gt;month_format("%B"); // full name
2399   date_output-&gt;weekday_format("%A"); // full name
2400   date_input-&gt;weekday_format("%A"); // full name
2401
2402   ss.str("");
2403   ss &lt;&lt; greg_month(3);
2404   cout &lt;&lt; ss.str() &lt;&lt; endl; // "march"
2405   ss.str("");
2406   ss &lt;&lt; greg_weekday(3);
2407   cout &lt;&lt; ss.str() &lt;&lt; endl; // "tuesday"
2408   ss.str("");
2409   ss &lt;&lt; date(2005,Jul,4);
2410   cout &lt;&lt; ss.str() &lt;&lt; endl; // "2005-july-04"
2411     
2412   </pre>
2413 <a name="tut_sv"></a><h5>
2414 <a name="idp180857360"></a>Special Values</h5>
2415 <p>Customizing the input and output of special values is best done by creating a new special_values_parser and special_values_formatter. The new strings can be set at construction time (as in the example below).</p>
2416   (continued from previous example)
2417   <pre class="programlisting">
2418     
2419   // reset the formats to defaults
2420   output_facet-&gt;format(local_time_facet::default_time_format);
2421   input_facet-&gt;format(local_time_input_facet::default_time_input_format);
2422
2423   // create custom special_values parser and formatter objects
2424   // and add them to the facets
2425   string sv[5] = {"nadt","neg_inf", "pos_inf", "min_dt", "max_dt" };
2426   vector&lt;string&gt; sv_names(&amp;sv[0], &amp;sv[5]);
2427   special_values_parser sv_parser(sv_names.begin(), sv_names.end());
2428   special_values_formatter sv_formatter(sv_names.begin(), sv_names.end());
2429   output_facet-&gt;special_values_formatter(sv_formatter);
2430   input_facet-&gt;special_values_parser(sv_parser);
2431
2432   ss.str("");
2433   ldt = local_date_time(not_a_date_time);
2434   ss &lt;&lt; ldt;
2435   cout &lt;&lt; ss.str() &lt;&lt; endl; // "nadt"
2436   
2437   ss.str("min_dt");
2438   ss &gt;&gt; ldt;
2439   ss.str("");
2440   ss &lt;&lt; ldt;
2441   cout &lt;&lt; ss.str() &lt;&lt; endl; // "1400-Jan-01 00:00:00 UTC"
2442     
2443   </pre>
2444 <p>NOTE: even though we sent in strings for min and max to the formatter, they are ignored because those special values construct to actual dates (as shown above).</p>
2445 <a name="tut_dper"></a><h5>
2446 <a name="idp180862080"></a>Date/Time Periods</h5>
2447 <p>Customizing the input and output of periods is best done by creating a new period_parser and period_formatter. The new strings can be set at construction time (as in the example below).</p>
2448   (continued from previous example)
2449   <pre class="programlisting">
2450     
2451   // all formats set back to defaults (not shown for brevity)
2452
2453   // create our date_period
2454   date_period dp(date(2005,Mar,1), days(31)); // month of march
2455
2456   // custom period formatter and parser
2457   period_formatter per_formatter(period_formatter::AS_OPEN_RANGE, 
2458                                  " to ", "from ", " exclusive", " inclusive" );
2459   period_parser per_parser(period_parser::AS_OPEN_RANGE, 
2460                            " to ", "from ", " exclusive" , "inclusive" );
2461   
2462   // default output
2463   ss.str("");
2464   ss &lt;&lt; dp;
2465   cout &lt;&lt; ss.str() &lt;&lt; endl; // "[2005-Mar-01/2005-Mar-31]"
2466  
2467   // add out custom parser and formatter to  the facets
2468   date_output-&gt;period_formatter(per_formatter);
2469   date_input-&gt;period_parser(per_parser);
2470   
2471   // custom output
2472   ss.str("");
2473   ss &lt;&lt; dp;
2474   cout &lt;&lt; ss.str() &lt;&lt; endl; // "from 2005-Feb-01 to 2005-Apr-01 exclusive"
2475     
2476   </pre>
2477 <a name="tut_dgen"></a><h5>
2478 <a name="idp180865760"></a>Date Generators</h5>
2479 <p>Customizing the input and output of date_generators is done by replacing the existing strings (in the facet) with new strings.</p>
2480 <p>NOTE: We've shown earlier that the components of a date/time representation can be re-ordered via the format string. This is not the case with date_generators. The elements themselves can be customized but their order cannot be changed.</p>
2481   (continued from previous example)
2482   <pre class="programlisting">
2483     
2484   // custom date_generator phrases
2485   string dg_phrases[9] = { "1st", "2nd", "3rd", "4th", "5th", 
2486                            "final", "prior to", "following", "in" };
2487   vector&lt;string&gt; phrases(&amp;dg_phrases[0], &amp;dg_phrases[9]);
2488
2489   // create our date_generator
2490   first_day_of_the_week_before d_gen(Monday);
2491
2492   // default output
2493   ss.str("");
2494   ss &lt;&lt; d_gen;
2495   cout &lt;&lt; ss.str() &lt;&lt; endl; // "Mon before"
2496  
2497   // add our custom strings to the date facets
2498   date_output-&gt;date_gen_phrase_strings(phrases);
2499   date_input-&gt;date_gen_element_strings(phrases);
2500   
2501   // custom output
2502   ss.str("");
2503   ss &lt;&lt; d_gen;
2504   cout &lt;&lt; ss.str() &lt;&lt; endl; // "Mon prior to"
2505     
2506   </pre>
2507 </div>
2508 </div>
2509 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
2510 <td align="left"></td>
2511 <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
2512     <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>
2513 </div></td>
2514 </tr></table>
2515 <hr>
2516 <div class="spirit-nav">
2517 <a accesskey="p" href="local_time.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../date_time.html"><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="serialization.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
2518 </div>
2519 </body>
2520 </html>