1 | <?xml version="1.0" encoding="utf-8"?> |
---|
2 | <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" |
---|
3 | "../../../tools/boostbook/dtd/boostbook.dtd"> |
---|
4 | |
---|
5 | <!-- Copyright (c) 2005 CrystalClear Software, Inc. |
---|
6 | Subject to the Boost Software License, Version 1.0. |
---|
7 | (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0) |
---|
8 | --> |
---|
9 | |
---|
10 | <section id="date_time.time_facet"> |
---|
11 | <title>Time Facet</title> |
---|
12 | |
---|
13 | <link linkend="time_facet_intro">Introduction</link> - |
---|
14 | <link linkend="time_facet_constr">Construction</link> - |
---|
15 | <link linkend="time_facet_accessors">Accessors</link> |
---|
16 | |
---|
17 | <anchor id="time_facet_intro" /> |
---|
18 | <bridgehead renderas="sect3">Introduction</bridgehead> |
---|
19 | <para>The <code>boost::date_time::time_facet</code> is an extension of the <code>boost::date_time::date_facet</code>. The time_facet is typedef'ed in the <code>posix_time</code> namespace as <code>time_facet</code> and <code>wtime_facet</code>. It is typedef'd in the <code>local_time</code> namespace as <code>local_time_facet</code> and <code>wlocal_time_facet</code>. |
---|
20 | </para> |
---|
21 | |
---|
22 | <anchor id="time_facet_constr" /> |
---|
23 | <bridgehead renderas="sect3">Construction</bridgehead> |
---|
24 | <para> |
---|
25 | <informaltable frame="all"> |
---|
26 | <tgroup cols="2"> |
---|
27 | <thead> |
---|
28 | <row> |
---|
29 | <entry>Syntax</entry> |
---|
30 | <entry>Description</entry> |
---|
31 | </row> |
---|
32 | </thead> |
---|
33 | <tbody> |
---|
34 | <row> |
---|
35 | <entry valign="top"><screen>time_facet()</screen></entry> |
---|
36 | <entry>Default constructor</entry> |
---|
37 | </row> |
---|
38 | <row> |
---|
39 | <entry valign="top"><screen>time_facet(...) |
---|
40 | Parameters: |
---|
41 | char_type* format |
---|
42 | period_formatter_type |
---|
43 | special_values_formatter_type |
---|
44 | date_gen_formatter_type</screen></entry> |
---|
45 | <entry>Format given will be used for time output. The remaining parameters are formatter objects. Further details on these objects can be found <link linkend="date_time.io_objects">here</link>. This constructor also provides default arguments for all parameters except the format. Therefore, <code>time_facet("%H:%M:S %m %d %Y")</code> will work.</entry> |
---|
46 | </row> |
---|
47 | </tbody> |
---|
48 | </tgroup> |
---|
49 | </informaltable> |
---|
50 | </para> |
---|
51 | |
---|
52 | <anchor id="time_facet_accessors" /> |
---|
53 | <bridgehead renderas="sect3">Accessors</bridgehead> |
---|
54 | <para> |
---|
55 | 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 <link linkend="date_time.date_facet">this</link> link. |
---|
56 | <informaltable frame="all"> |
---|
57 | <tgroup cols="2"> |
---|
58 | <thead> |
---|
59 | <row> |
---|
60 | <entry valign="top" morerows="1">Syntax</entry> |
---|
61 | <entry>Description</entry> |
---|
62 | </row> |
---|
63 | <row> |
---|
64 | <entry>Example</entry> |
---|
65 | </row> |
---|
66 | </thead> |
---|
67 | <tbody> |
---|
68 | <row> |
---|
69 | <entry valign="top" morerows="1"><screen>void time_duration_format(...) |
---|
70 | Parameter: |
---|
71 | char_type*</screen></entry> |
---|
72 | <entry>Sets the time_duration format. The time_duration format has the ability to display the sign of the duration. The <code>'%+'</code> flag will always display the sign. The <code>'%-'</code> will only display if the sign is negative. Currently the '-' and '+' characters are used to denote the sign.</entry> |
---|
73 | </row> |
---|
74 | <row> |
---|
75 | <entry><screen>f->time_duration_format("%+%H:%M"); |
---|
76 | // hours and minutes only w/ sign always displayed |
---|
77 | time_duration td1(3, 15, 56); |
---|
78 | time_duration td2(-12, 25, 32); |
---|
79 | ss << td1; // "+03:15:56" |
---|
80 | ss << td2; // "-12:25:56" |
---|
81 | </screen></entry> |
---|
82 | </row> |
---|
83 | |
---|
84 | <row> |
---|
85 | <entry valign="top" morerows="1"><screen>void set_iso_format()</screen></entry> |
---|
86 | <entry>Sets the date and time format to ISO.</entry> |
---|
87 | </row> |
---|
88 | <row> |
---|
89 | <entry><screen>f->set_iso_format(); |
---|
90 | // "%Y%m%dT%H%M%S%F%q"</screen></entry> |
---|
91 | </row> |
---|
92 | |
---|
93 | <row> |
---|
94 | <entry valign="top" morerows="1"><screen>void set_iso_extended_format()</screen></entry> |
---|
95 | <entry>Sets the date and time format to ISO Extended</entry> |
---|
96 | </row> |
---|
97 | <row> |
---|
98 | <entry><screen>f->set_iso_extended_format(); |
---|
99 | // "%Y-%m-%d %H:%M:%S%F%Q"</screen></entry> |
---|
100 | </row> |
---|
101 | |
---|
102 | <row> |
---|
103 | <entry valign="top" morerows="1"><screen>OutItrT put(...) |
---|
104 | Common parameters for all |
---|
105 | 'put' functions: |
---|
106 | OutItrT |
---|
107 | ios_base |
---|
108 | char_type |
---|
109 | Unique parameter for 'put' funcs: |
---|
110 | posix_time object</screen></entry> |
---|
111 | <entry>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.</entry> |
---|
112 | </row> |
---|
113 | <row> |
---|
114 | <entry><screen></screen></entry> |
---|
115 | </row> |
---|
116 | |
---|
117 | <row> |
---|
118 | <entry valign="top" morerows="1"><screen>OutItrT put(..., ptime)</screen></entry> |
---|
119 | <entry>Puts a ptime object into the stream using the format set by <code>format(...)</code> or the default.</entry> |
---|
120 | </row> |
---|
121 | <row> |
---|
122 | <entry><screen></screen></entry> |
---|
123 | </row> |
---|
124 | |
---|
125 | <row> |
---|
126 | <entry valign="top" morerows="1"><screen>OutItrT put(..., time_duration)</screen></entry> |
---|
127 | <entry>Puts a time_duration object into the stream using the format set by <code>time_duration_format(...)</code> or the default.</entry> |
---|
128 | </row> |
---|
129 | <row> |
---|
130 | <entry><screen></screen></entry> |
---|
131 | </row> |
---|
132 | |
---|
133 | <row> |
---|
134 | <entry valign="top" morerows="1"><screen>OutItrT put(..., time_period)</screen></entry> |
---|
135 | <entry>Puts a time_period into the stream. The format of the dates and times will use the format set by <code>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.</entry> |
---|
136 | </row> |
---|
137 | <row> |
---|
138 | <entry><screen></screen></entry> |
---|
139 | </row> |
---|
140 | |
---|
141 | </tbody> |
---|
142 | </tgroup> |
---|
143 | </informaltable> |
---|
144 | </para> |
---|
145 | </section> |
---|
146 | |
---|
147 | |
---|