date_input_facet.xml 14 KB

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