1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
|
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
"../../../tools/boostbook/dtd/boostbook.dtd">
<!-- Copyright (c) 2005 CrystalClear Software, Inc.
Subject to the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
-->
<section id="date_time.date_input_facet">
<title>Date Input Facet</title>
<link linkend="date_input_facet_intro">Introduction</link> -
<link linkend="date_input_facet_constr">Construction</link> -
<link linkend="date_input_facet_accessors">Accessors</link>
<anchor id="date_input_facet_intro" />
<bridgehead renderas="sect3">Introduction</bridgehead>
<para>The <code>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>gregorian</code> namespace as <code>date_input_facet</code> and <code>wdate_input_facet</code>.
</para>
<anchor id="date_input_facet_constr" />
<bridgehead renderas="sect3">Construction</bridgehead>
<para>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry>Syntax</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top"><screen>date_input_facet()</screen></entry>
<entry>Default constructor</entry>
</row>
<row>
<entry valign="top"><screen>date_input_facet(string_type format)</screen></entry>
<entry>Format given will be used for date input. All other formats will use their defaults.</entry>
</row>
<row>
<entry valign="top"><screen>date_input_facet(...)
Parameters:
string_type format
format_date_parser_type
special_values_parser_type
period_parser_type
date_gen_parser_type</screen></entry>
<entry>Format given will be used for date input. The remaining parameters are parser objects. Further details on these objects can be found <link linkend="date_time.io_objects">here</link>.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<anchor id="date_input_facet_accessors" />
<bridgehead renderas="sect3">Accessors</bridgehead>
<para>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top" morerows="1">Syntax</entry>
<entry>Description</entry>
</row>
<row>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top" morerows="1"><screen>void format(char_type*)</screen></entry>
<entry>Set the format for dates.</entry>
</row>
<row>
<entry><screen>date_input_facet* f =
new date_input_facet();
f->format("%m %d %Y");</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void set_iso_format()</screen></entry>
<entry>Sets the date format to ISO</entry>
</row>
<row>
<entry><screen>f->set_iso_format();
// "%Y%m%d"</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void set_iso_extended_format()</screen></entry>
<entry>Sets the date format to ISO Extended</entry>
</row>
<row>
<entry><screen>f->set_iso_extended_format();
// "%Y-%m-%d"</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void month_format(char_type*)</screen></entry>
<entry>Set the format when 'get'ing months individually.</entry>
</row>
<row>
<entry><screen>f->month_format("%B");
ss.str("March");
ss >> m; // March</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void weekday_format(char_type*)</screen></entry>
<entry>Set the format when 'get'ing weekdays individually.</entry>
</row>
<row>
<entry><screen>f->weekday_format("%a");
ss.str("Sun");
ss >> wd; // Sunday</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void year_format(char_type*)</screen></entry>
<entry>Set the format when 'get'ing years individually.</entry>
</row>
<row>
<entry><screen>f->weekday_format("%y");
ss.str("04");
ss >> year; // 2004</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void period_parser(...)
Parameter:
period_parser_type</screen></entry>
<entry>Replaces the period parser object with a user created one.</entry>
</row>
<row>
<entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void special_values_parser(...)
Parameter:
special_values_parser_type</screen></entry>
<entry>Replaces the special_values parser object with a user created one.</entry>
</row>
<row>
<entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void date_gen_phrase_strings(...)
Parameters:
input_collection_type</screen></entry>
<entry>Sets new date generator phrase strings in date_gen_parser. The input collection is a vector of strings (for details on these strings see <link linkend="io_objects.date_generators">date generator formatter/parser documentation</link>).</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void short_weekday_names(...)
Parameter:
input_collection_type</screen></entry>
<entry>Replace strings used when 'getting' short weekdays.</entry>
</row>
<row>
<entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void long_weekday_names(...)
Parameter:
input_collection_type</screen></entry>
<entry>Replace strings used when 'getting' long weekdays.</entry>
</row>
<row>
<entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void short_month_names(...)
Parameter:
input_collection_type</screen></entry>
<entry>Replace strings used when 'getting' short months.</entry>
</row>
<row>
<entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void long_month_names(...)
Parameter:
input_collection_type</screen></entry>
<entry>Replace strings used when 'getting' long months.</entry>
</row>
<row>
<entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(...)
Common parameters for all
'get' functions:
InItrT from
InItrT to
ios_base
Unique parameter for 'get' funcs:
gregorian object</screen></entry>
<entry>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.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., date)</screen></entry>
<entry>Gets a date object from the stream using the format set by <code>format(...)</code> or the default.</entry>
</row>
<row>
<entry><screen>ss.str("2005-Jan-01");
ss >> d; // default format</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., month)</screen></entry>
<entry>Gets a month object from the stream using the format set by <code>month_format(...)</code> or the default.</entry>
</row>
<row>
<entry><screen>ss.str("Feb");
ss >> m; // default format</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., day_of_week)</screen></entry>
<entry>Gets a day of week object from the stream using the format set by <code>weekday_format(...)</code> or the default.</entry>
</row>
<row>
<entry><screen>ss.str("Sun");
ss >> dow; // default format</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., day)</screen></entry>
<entry>Gets a day of month object from the stream as a two digit number.</entry>
</row>
<row>
<entry><screen>"01" // January 1st</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., year)</screen></entry>
<entry>Gets a year object from the stream as a number. The number of expected digits depends on the year format.</entry>
</row>
<row>
<entry><screen>ss/str("2005");
ss >> y; // default format</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., days)</screen></entry>
<entry>Gets a days object from the stream as a number.</entry>
</row>
<row>
<entry><screen>ss.str("356");
ss >> dys; // a full year</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., date_period)</screen></entry>
<entry>Gets a date_period from the stream. The format of the dates will use the format set by <code>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.</entry>
</row>
<row>
<entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., partial_date)</screen></entry>
<entry>Gets a partial_date date_generator object from the stream. The month format used is set by <code>month_format(..)</code> or the default. The day of month is represented as a two digit number.</entry>
</row>
<row>
<entry><screen>"01 Jan" // default formats
"01 January" // long month format</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., date_generator)
Date Generator Type:
nth_day_of_the_week_in_month</screen></entry>
<entry>Gets a nth_day_of_the_week_in_month object from the stream. The month format is set by <code>month_format(...)</code> or the default. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_parser</link>.</entry>
</row>
<row>
<entry><screen>"third Fri in May" // defaults</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., date_generator)
Date Generator Type:
first_day_of_the_week_in_month</screen></entry>
<entry>Gets a first_day_of_the_week_in_month object from the stream. The month format is set by <code>month_format(...)</code> or the default. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_parser</link>.</entry>
</row>
<row>
<entry><screen>"first Wed of Jun" // defaults</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., date_generator)
Date Generator Type:
last_day_of_the_week_in_month</screen></entry>
<entry>Gets a last_day_of_the_week_in_month object from the stream. The month format is set by <code>month_format(...)</code> or the default. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_parser</link>.</entry>
</row>
<row>
<entry><screen>"last Tue of Mar" // defaults</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., date_generator)
Date Generator Type:
first_day_of_the_week_after</screen></entry>
<entry>Gets a first_day_of_the_week_after object from the stream. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_parser</link>.</entry>
</row>
<row>
<entry><screen>"first Sat after" // defaults</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>InItrT get(..., date_generator)
Date Generator Type:
first_day_of_the_week_before</screen></entry>
<entry>Gets a first_day_of_the_week_before object from the stream. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_parser</link>.</entry>
</row>
<row>
<entry><screen>"first Mon before" // defaults</screen></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</section>
|