time_facet.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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.time_facet">
  9. <title>Time Facet</title>
  10. <link linkend="time_facet_intro">Introduction</link> -
  11. <link linkend="time_facet_constr">Construction</link> -
  12. <link linkend="time_facet_accessors">Accessors</link>
  13. <anchor id="time_facet_intro" />
  14. <bridgehead renderas="sect3">Introduction</bridgehead>
  15. <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>.
  16. </para>
  17. <anchor id="time_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>time_facet()</screen></entry>
  31. <entry>Default constructor</entry>
  32. </row>
  33. <row>
  34. <entry valign="top"><screen>time_facet(...)
  35. Parameters:
  36. char_type* format
  37. period_formatter_type
  38. special_values_formatter_type
  39. date_gen_formatter_type</screen></entry>
  40. <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>
  41. </row>
  42. </tbody>
  43. </tgroup>
  44. </informaltable>
  45. </para>
  46. <anchor id="time_facet_accessors" />
  47. <bridgehead renderas="sect3">Accessors</bridgehead>
  48. <para>
  49. 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.
  50. <informaltable frame="all">
  51. <tgroup cols="2">
  52. <thead>
  53. <row>
  54. <entry valign="top" morerows="1">Syntax</entry>
  55. <entry>Description</entry>
  56. </row>
  57. <row>
  58. <entry>Example</entry>
  59. </row>
  60. </thead>
  61. <tbody>
  62. <row>
  63. <entry valign="top" morerows="1"><screen>void time_duration_format(...)
  64. Parameter:
  65. char_type*</screen></entry>
  66. <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>
  67. </row>
  68. <row>
  69. <entry><screen>f->time_duration_format("%+%H:%M");
  70. // hours and minutes only w/ sign always displayed
  71. time_duration td1(3, 15, 56);
  72. time_duration td2(-12, 25, 32);
  73. ss &lt;&lt; td1; // "+03:15:56"
  74. ss &lt;&lt; td2; // "-12:25:56"
  75. </screen></entry>
  76. </row>
  77. <row>
  78. <entry valign="top" morerows="1"><screen>void set_iso_format()</screen></entry>
  79. <entry>Sets the date and time format to ISO.</entry>
  80. </row>
  81. <row>
  82. <entry><screen>f->set_iso_format();
  83. // "%Y%m%dT%H%M%S%F%q"</screen></entry>
  84. </row>
  85. <row>
  86. <entry valign="top" morerows="1"><screen>void set_iso_extended_format()</screen></entry>
  87. <entry>Sets the date and time format to ISO Extended</entry>
  88. </row>
  89. <row>
  90. <entry><screen>f->set_iso_extended_format();
  91. // "%Y-%m-%d %H:%M:%S%F%Q"</screen></entry>
  92. </row>
  93. <row>
  94. <entry valign="top" morerows="1"><screen>OutItrT put(...)
  95. Common parameters for all
  96. 'put' functions:
  97. OutItrT
  98. ios_base
  99. char_type
  100. Unique parameter for 'put' funcs:
  101. posix_time object</screen></entry>
  102. <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>
  103. </row>
  104. <row>
  105. <entry><screen></screen></entry>
  106. </row>
  107. <row>
  108. <entry valign="top" morerows="1"><screen>OutItrT put(..., ptime)</screen></entry>
  109. <entry>Puts a ptime object into the stream using the format set by <code>format(...)</code> or the default.</entry>
  110. </row>
  111. <row>
  112. <entry><screen></screen></entry>
  113. </row>
  114. <row>
  115. <entry valign="top" morerows="1"><screen>OutItrT put(..., time_duration)</screen></entry>
  116. <entry>Puts a time_duration object into the stream using the format set by <code>time_duration_format(...)</code> or the default.</entry>
  117. </row>
  118. <row>
  119. <entry><screen></screen></entry>
  120. </row>
  121. <row>
  122. <entry valign="top" morerows="1"><screen>OutItrT put(..., time_period)</screen></entry>
  123. <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>
  124. </row>
  125. <row>
  126. <entry><screen></screen></entry>
  127. </row>
  128. </tbody>
  129. </tgroup>
  130. </informaltable>
  131. </para>
  132. </section>