time_duration.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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) 2001-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.posix_time.time_duration">
  9. <title>Time Duration</title>
  10. <link linkend="time_duration_intro">Introduction</link> --
  11. <link linkend="time_duration_header">Header</link> --
  12. <link linkend="time_duration_constr">Construction</link> --
  13. <link linkend="time_duration_count_constr">Count Based Construction</link> --
  14. <link linkend="time_duration_from_string">Construct from String</link> --
  15. <link linkend="time_duration_accessors">Accessors</link> --
  16. <link linkend="time_duration_to_string">Conversion To String</link> --
  17. <link linkend="time_duration_operators">Operators</link> --
  18. <link linkend="time_duration_struct_tm">Struct tm Functions</link>
  19. <anchor id="time_duration_intro" />
  20. <bridgehead renderas="sect3">Introduction</bridgehead>
  21. <para>
  22. The class boost::posix_time::time_duration the base type responsible for representing a length of time. A duration can be either positive or negative. The general time_duration class provides a constructor that takes a count of the number of hours, minutes, seconds, and fractional seconds count as shown in the code fragment below. The resolution of the time_duration is configure able at compile time. See <link linkend="date_time.buildinfo">Build-Compiler Information</link> for more information.
  23. </para>
  24. <para>
  25. <programlisting>using namespace boost::posix_time;
  26. time_duration td(1,2,3,4); //01:02:03.000000004 when resolution is nano seconds
  27. time_duration td(1,2,3,4); //01:02:03.000004 when resolution is micro seconds</programlisting>
  28. </para>
  29. <para>
  30. Several small helper classes that derive from a base time_duration, as shown below, to adjust for different resolutions. These classes can shorten code and make the intent clearer.
  31. </para>
  32. <imagedata fileref="../../libs/date_time/doc/time_duration_inherit.png" />
  33. <para>
  34. As an example:
  35. <programlisting>using namespace boost::posix_time;
  36. time_duration td = hours(1) + seconds(10); //01:00:10
  37. td = hours(1) + nanoseconds(5); //01:00:00.000000005</programlisting>
  38. Note that the existence of the higher resolution classes (eg: nanoseconds) depends on the installation of the library. See <link linkend="date_time.buildinfo">Build-Compiler Information</link> for more information.
  39. </para>
  40. <para>
  41. Another way to handle this is to utilize the ticks_per_second() method of time_duration to
  42. write code that is portable no matter how the library is compiled. The general equation
  43. for calculating a resolution independent count is as follows:
  44. <programlisting>
  45. count*(time_duration_ticks_per_second / count_ticks_per_second)
  46. </programlisting>
  47. For example, let's suppose we want to construct using a count that represents tenths
  48. of a second. That is, each tick is 0.1 second.
  49. <programlisting>
  50. int number_of_tenths = 5;
  51. //create a resolution independent count -- divide by 10 since there are
  52. //10 tenths in a second.
  53. int count = number_of_tenths*(time_duration::ticks_per_second()/10);
  54. time_duration td(1,2,3,count); //01:02:03.5 //no matter the resolution settings
  55. </programlisting>
  56. </para>
  57. <anchor id="time_duration_header" />
  58. <bridgehead renderas="sect3">Header</bridgehead>
  59. <para>
  60. <programlisting>#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
  61. or
  62. #include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types</programlisting>
  63. </para>
  64. <anchor id="time_duration_constr" />
  65. <bridgehead renderas="sect3">Construction</bridgehead>
  66. <para>
  67. <informaltable frame="all">
  68. <tgroup cols="2">
  69. <thead>
  70. <row>
  71. <entry valign="top" morerows="1">Syntax</entry>
  72. <entry>Description</entry>
  73. </row>
  74. <row>
  75. <entry>Example</entry>
  76. </row>
  77. </thead>
  78. <tbody>
  79. <row>
  80. <entry valign="top" morerows="1"><screen>time_duration(hours,
  81. minutes,
  82. seconds,
  83. fractional_seconds)</screen></entry>
  84. <entry>Construct a duration from the counts. The fractional_second parameter is a number of units and is therefore affected by the resolution the application is compiled with (see <link linkend="compile_options">Build-Compiler Information</link>). If the fractional_seconds argument exceeds the limit of the compiled precision, the excess value will be "carried over" into the seconds field. See above for techniques to creating a resolution independent count.</entry>
  85. </row>
  86. <row>
  87. <entry><screen>time_duration td(1,2,3,9);
  88. //1 hr 2 min 3 sec 9 nanoseconds
  89. time_duration td2(1,2,3,123456789);
  90. time_duration td3(1,2,3,1000);
  91. // with microsecond resolution (6 digits)
  92. // td2 => "01:04:06.456789"
  93. // td3 => "01:02:03.001000"
  94. // with nanosecond resolution (9 digits)
  95. // td2 => "01:02:03.123456789"
  96. // td3 => "01:02:03.000001000"</screen></entry>
  97. </row>
  98. <row>
  99. <entry valign="top"><screen>time_duration(special_value sv)</screen></entry>
  100. <entry>Special values constructor. <emphasis role="strong">Important note</emphasis>: When a time_duration is a special value, either by construction or other means, the following accessor functions will give unpredictable results: <screen>hours(), minutes(), seconds(), ticks(),
  101. fractional_seconds(), total_nanoseconds(),
  102. total_microseconds(), total_milliseconds(),
  103. total_seconds()</screen>The remaining accessor functions will work as expected.</entry>
  104. </row>
  105. </tbody>
  106. </tgroup>
  107. </informaltable>
  108. </para>
  109. <anchor id="time_duration_count_constr" />
  110. <bridgehead renderas="sect3">Count Based Construction</bridgehead>
  111. <para>
  112. <informaltable frame="all">
  113. <tgroup cols="2">
  114. <thead>
  115. <row>
  116. <entry valign="top" morerows="1">Syntax</entry>
  117. <entry>Description</entry>
  118. </row>
  119. <row>
  120. <entry>Example</entry>
  121. </row>
  122. </thead>
  123. <tbody>
  124. <row>
  125. <entry valign="top" morerows="1"><screen>hours(long)</screen></entry>
  126. <entry>Number of hours</entry>
  127. </row>
  128. <row>
  129. <entry><screen>time_duration td = hours(3);</screen></entry>
  130. </row>
  131. <row>
  132. <entry valign="top" morerows="1"><screen>minutes(long)</screen></entry>
  133. <entry>Number of minutes</entry>
  134. </row>
  135. <row>
  136. <entry><screen>time_duration td = minutes(3);</screen></entry>
  137. </row>
  138. <row>
  139. <entry valign="top" morerows="1"><screen>seconds(long)</screen></entry>
  140. <entry> Number of seconds</entry>
  141. </row>
  142. <row>
  143. <entry><screen>time_duration td = seconds(3);</screen></entry>
  144. </row>
  145. <row>
  146. <entry valign="top" morerows="1"><screen>milliseconds(long)</screen></entry>
  147. <entry>Number of milliseconds.</entry>
  148. </row>
  149. <row>
  150. <entry><screen>time_duration td = milliseconds(3);</screen></entry>
  151. </row>
  152. <row>
  153. <entry valign="top" morerows="1"><screen>microseconds(long)</screen></entry>
  154. <entry>Number of microseconds.</entry>
  155. </row>
  156. <row>
  157. <entry><screen>time_duration td = microseconds(3);</screen></entry>
  158. </row>
  159. <row>
  160. <entry valign="top" morerows="1"><screen>nanoseconds(long)</screen></entry>
  161. <entry>Number of nanoseconds.</entry>
  162. </row>
  163. <row>
  164. <entry><screen>time_duration td = nanoseconds(3);</screen></entry>
  165. </row>
  166. </tbody>
  167. </tgroup>
  168. </informaltable>
  169. </para>
  170. <anchor id="time_duration_from_string" />
  171. <bridgehead renderas="sect3">Construct from String</bridgehead>
  172. <para>
  173. <informaltable frame="all">
  174. <tgroup cols="2">
  175. <thead>
  176. <row>
  177. <entry valign="top" morerows="1">Syntax</entry>
  178. <entry>Description</entry>
  179. </row>
  180. <row>
  181. <entry>Example</entry>
  182. </row>
  183. </thead>
  184. <tbody>
  185. <row>
  186. <entry valign="top" morerows="1"><screen>time_duration duration_from_string(std::string)</screen></entry>
  187. <entry>From delimited string. NOTE: Excess digits in fractional seconds will be dropped. Ex: "1:02:03.123456999" =&gt; 1:02:03.123456. This behavior is affected by the precision the library is compiled with (see <link linkend="date_time.buildinfo">Build-Compiler Information</link>.</entry>
  188. </row>
  189. <row>
  190. <entry><screen>std::string ts("23:59:59.000");
  191. time_duration td(duration_from_string(ts));</screen>
  192. </entry>
  193. </row>
  194. </tbody>
  195. </tgroup>
  196. </informaltable>
  197. </para>
  198. <anchor id="time_duration_accessors" />
  199. <bridgehead renderas="sect3">Accessors</bridgehead>
  200. <para>
  201. <informaltable frame="all">
  202. <tgroup cols="2">
  203. <thead>
  204. <row>
  205. <entry valign="top" morerows="1">Syntax</entry>
  206. <entry>Description</entry>
  207. </row>
  208. <row>
  209. <entry>Example</entry>
  210. </row>
  211. </thead>
  212. <tbody>
  213. <row>
  214. <entry valign="top" morerows="1"><screen>boost::int64_t hours()</screen></entry>
  215. <entry>Get the number of normalized hours (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
  216. </row>
  217. <row>
  218. <entry><screen>time_duration td(1,2,3);
  219. time_duration neg_td(-1,2,3);
  220. td.hours(); // --> 1
  221. neg_td.hours(); // --> -1</screen></entry>
  222. </row>
  223. <row>
  224. <entry valign="top" morerows="1"><screen>boost::int64_t minutes()</screen></entry>
  225. <entry>Get the number of minutes normalized +/-(0..59) (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
  226. </row>
  227. <row>
  228. <entry><screen>time_duration td(1,2,3);
  229. time_duration neg_td(-1,2,3);
  230. td.minutes(); // --> 2
  231. neg_td.minutes(); // --> -2</screen></entry>
  232. </row>
  233. <row>
  234. <entry valign="top" morerows="1"><screen>boost::int64_t seconds() const</screen></entry>
  235. <entry>Get the normalized number of second +/-(0..59) (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
  236. </row>
  237. <row>
  238. <entry><screen>time_duration td(1,2,3);
  239. time_duration neg_td(-1,2,3);
  240. td.seconds(); // --> 3
  241. neg_td.seconds(); // --> -3</screen></entry>
  242. </row>
  243. <row>
  244. <entry valign="top" morerows="1"><screen>boost::int64_t total_seconds() const</screen></entry>
  245. <entry>Get the total number of seconds truncating any fractional seconds (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
  246. </row>
  247. <row>
  248. <entry><screen>time_duration td(1,2,3,10);
  249. td.total_seconds();
  250. // --> (1*3600) + (2*60) + 3 == 3723</screen>
  251. </entry>
  252. </row>
  253. <row>
  254. <entry valign="top" morerows="1"><screen>boost::int64_t total_milliseconds() const</screen></entry>
  255. <entry>Get the total number of milliseconds truncating any remaining digits (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
  256. </row>
  257. <row>
  258. <entry><screen>time_duration td(1,2,3,123456789);
  259. td.total_milliseconds();
  260. // HMS --> (1*3600) + (2*60) + 3 == 3723 seconds
  261. // milliseconds is 3 decimal places
  262. // (3723 * 1000) + 123 == 3723123</screen>
  263. </entry>
  264. </row>
  265. <row>
  266. <entry valign="top" morerows="1"><screen>boost::int64_t total_microseconds() const</screen></entry>
  267. <entry>Get the total number of microseconds truncating any remaining digits (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
  268. </row>
  269. <row>
  270. <entry><screen>time_duration td(1,2,3,123456789);
  271. td.total_microseconds();
  272. // HMS --> (1*3600) + (2*60) + 3 == 3723 seconds
  273. // microseconds is 6 decimal places
  274. // (3723 * 1000000) + 123456 == 3723123456</screen>
  275. </entry>
  276. </row>
  277. <row>
  278. <entry valign="top" morerows="1"><screen>boost::int64_t total_nanoseconds() const</screen></entry>
  279. <entry>Get the total number of nanoseconds truncating any remaining digits (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
  280. </row>
  281. <row>
  282. <entry><screen>time_duration td(1,2,3,123456789);
  283. td.total_nanoseconds();
  284. // HMS --> (1*3600) + (2*60) + 3 == 3723 seconds
  285. // nanoseconds is 9 decimal places
  286. // (3723 * 1000000000) + 123456789
  287. // == 3723123456789</screen>
  288. </entry>
  289. </row>
  290. <row>
  291. <entry valign="top" morerows="1"><screen>boost::int64_t fractional_seconds() const</screen></entry>
  292. <entry>Get the number of fractional seconds (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
  293. </row>
  294. <row>
  295. <entry><screen>time_duration td(1,2,3, 1000);
  296. td.fractional_seconds(); // --> 1000</screen></entry>
  297. </row>
  298. <row>
  299. <entry valign="top" morerows="1"><screen>bool is_negative() const</screen></entry>
  300. <entry>True if and only if duration is negative.</entry>
  301. </row>
  302. <row>
  303. <entry><screen>time_duration td(-1,0,0);
  304. td.is_negative(); // --> true</screen></entry>
  305. </row>
  306. <row>
  307. <entry valign="top" morerows="1"><screen>bool is_zero() const</screen></entry>
  308. <entry>True if and only if duration is zero.</entry>
  309. </row>
  310. <row>
  311. <entry><screen>time_duration td(0,0,0);
  312. td.is_zero(); // --> true</screen></entry>
  313. </row>
  314. <row>
  315. <entry valign="top" morerows="1"><screen>bool is_positive() const</screen></entry>
  316. <entry>True if and only if duration is positive.</entry>
  317. </row>
  318. <row>
  319. <entry><screen>time_duration td(1,0,0);
  320. td.is_positive(); // --> true</screen></entry>
  321. </row>
  322. <row>
  323. <entry valign="top" morerows="1"><screen>time_duration invert_sign() const</screen></entry>
  324. <entry>Generate a new duration with the sign inverted.</entry>
  325. </row>
  326. <row>
  327. <entry><screen>time_duration td(-1,0,0);
  328. td.invert_sign(); // --> 01:00:00</screen></entry>
  329. </row>
  330. <row>
  331. <entry valign="top" morerows="1"><screen>time_duration abs() const</screen></entry>
  332. <entry>Generate a new duration with the absolute value of the time duration.</entry>
  333. </row>
  334. <row>
  335. <entry><screen>time_duration td(-1,0,0);
  336. td.abs(); // --> 01:00:00</screen></entry>
  337. <entry><screen>time_duration td(+1,0,0);
  338. td.abs(); // --> 01:00:00</screen></entry>
  339. </row>
  340. <row>
  341. <entry valign="top" morerows="1"><screen>date_time::time_resolutions time_duration::resolution()</screen></entry>
  342. <entry>Describes the resolution capability of the time_duration class. time_resolutions is an enum of resolution possibilities ranging from seconds to nanoseconds.</entry>
  343. </row>
  344. <row>
  345. <entry><screen>time_duration::resolution() --> nano</screen></entry>
  346. </row>
  347. <row>
  348. <entry valign="top" morerows="1"><screen>unsigned short time_duration::num_fractional_digits()</screen></entry>
  349. <entry>Returns the number of fractional digits the time resolution has.</entry>
  350. </row>
  351. <row>
  352. <entry><screen>unsigned short secs;
  353. secs = time_duration::num_fractional_digits();
  354. // 9 for nano, 6 for micro, etc.</screen></entry>
  355. </row>
  356. <row>
  357. <entry valign="top" morerows="1"><screen>boost::int64_t time_duration::ticks_per_second()</screen></entry>
  358. <entry>Return the number of ticks in a second. For example, if the duration supports nanoseconds then the returned result will be 1,000,000,000 (1e+9).</entry>
  359. </row>
  360. <row>
  361. <entry><screen>std::cout &lt;&lt; time_duration::ticks_per_second();</screen></entry>
  362. </row>
  363. <row>
  364. <entry valign="top" morerows="1"><screen>boost::int64_t ticks()</screen></entry>
  365. <entry>Return the raw count of the duration type (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
  366. </row>
  367. <row>
  368. <entry><screen>time_duration td(0,0,0, 1000);
  369. td.ticks() // --> 1000</screen></entry>
  370. </row>
  371. <row>
  372. <entry valign="top" morerows="1"><screen>time_duration time_duration::unit()</screen></entry>
  373. <entry>Return smallest possible unit of duration type (1 nanosecond).</entry>
  374. </row>
  375. <row>
  376. <entry><screen>time_duration::unit() --> time_duration(0,0,0,1)</screen></entry>
  377. </row>
  378. <row>
  379. <entry valign="top" morerows="1"><screen>bool is_neg_infinity() const</screen></entry>
  380. <entry>Returns true if time_duration is negative infinity</entry>
  381. </row>
  382. <row>
  383. <entry><screen>time_duration td(neg_infin);
  384. td.is_neg_infinity(); // --> true</screen></entry>
  385. </row>
  386. <row>
  387. <entry valign="top" morerows="1"><screen>bool is_pos_infinity() const</screen></entry>
  388. <entry>Returns true if time_duration is positive infinity</entry>
  389. </row>
  390. <row>
  391. <entry><screen>time_duration td(pos_infin);
  392. td.is_pos_infinity(); // --> true</screen></entry>
  393. </row>
  394. <row>
  395. <entry valign="top" morerows="1"><screen>bool is_not_a_date_time() const</screen></entry>
  396. <entry>Returns true if value is not a time</entry>
  397. </row>
  398. <row>
  399. <entry><screen>time_duration td(not_a_date_time);
  400. td.is_not_a_date_time(); // --> true</screen></entry>
  401. </row>
  402. <row>
  403. <entry valign="top" morerows="1"><screen>bool is_special() const</screen></entry>
  404. <entry>Returns true if time_duration is any <code>special_value</code></entry>
  405. </row>
  406. <row>
  407. <entry><screen>time_duration td(pos_infin);
  408. time_duration td2(not_a_date_time);
  409. time_duration td3(2,5,10);
  410. td.is_special(); // --> true
  411. td2.is_special(); // --> true
  412. td3.is_special(); // --> false</screen></entry>
  413. </row>
  414. </tbody>
  415. </tgroup>
  416. </informaltable>
  417. </para>
  418. <anchor id="time_duration_to_string" />
  419. <bridgehead renderas="sect3">Conversion To String</bridgehead>
  420. <para>
  421. <informaltable frame="all">
  422. <tgroup cols="2">
  423. <thead>
  424. <row>
  425. <entry valign="top" morerows="1">Syntax</entry>
  426. <entry>Description</entry>
  427. </row>
  428. <row>
  429. <entry>Example</entry>
  430. </row>
  431. </thead>
  432. <tbody>
  433. <row>
  434. <entry valign="top" morerows="1"><screen>std::string to_simple_string(time_duration)</screen></entry>
  435. <entry>To <code>HH:MM:SS.fffffffff</code> were <code>fff</code> is fractional seconds that are only included if non-zero.</entry>
  436. </row>
  437. <row>
  438. <entry><screen>10:00:01.123456789</screen></entry>
  439. </row>
  440. <row>
  441. <entry valign="top" morerows="1"><screen>std::string to_iso_string(time_duration)</screen></entry>
  442. <entry>Convert to form <code>HHMMSS,fffffffff</code>.</entry>
  443. </row>
  444. <row>
  445. <entry><screen>100001,123456789</screen></entry>
  446. </row>
  447. </tbody>
  448. </tgroup>
  449. </informaltable>
  450. </para>
  451. <anchor id="time_duration_operators" />
  452. <bridgehead renderas="sect3">Operators</bridgehead>
  453. <para>
  454. <informaltable frame="all">
  455. <tgroup cols="2">
  456. <thead>
  457. <row>
  458. <entry valign="top" morerows="1">Syntax</entry>
  459. <entry>Description</entry>
  460. </row>
  461. <row>
  462. <entry>Example</entry>
  463. </row>
  464. </thead>
  465. <tbody>
  466. <row>
  467. <entry valign="top" morerows="1"><screen>operator&lt;&lt;, operator&gt;&gt;</screen></entry>
  468. <entry>Streaming operators. <emphasis role="strong">Note:</emphasis> As of version 1.33, streaming operations have been greatly improved. See <link linkend="date_time.date_time_io">Date Time IO System</link> for more details (including exceptions and error conditions).</entry>
  469. </row>
  470. <row>
  471. <entry><screen>time_duration td(0,0,0);
  472. stringstream ss("14:23:11.345678");
  473. ss &gt;&gt; td;
  474. std::cout &lt;&lt; td; // "14:23:11.345678"
  475. </screen>
  476. </entry>
  477. </row>
  478. <row>
  479. <entry valign="top" morerows="1"><screen>operator==, operator!=,
  480. operator>, operator&lt;,
  481. operator>=, operator&lt;=</screen>
  482. </entry>
  483. <entry>A full complement of comparison operators</entry>
  484. </row>
  485. <row>
  486. <entry><screen>dd1 == dd2, etc</screen></entry>
  487. </row>
  488. <row>
  489. <entry valign="top" morerows="1"><screen>time_duration operator+(time_duration)</screen></entry>
  490. <entry>Add durations.</entry>
  491. </row>
  492. <row>
  493. <entry><screen>time_duration td1(hours(1)+minutes(2));
  494. time_duration td2(seconds(10));
  495. time_duration td3 = td1 + td2;</screen>
  496. </entry>
  497. </row>
  498. <row>
  499. <entry valign="top" morerows="1"><screen>time_duration operator-(time_duration)</screen></entry>
  500. <entry>Subtract durations.</entry>
  501. </row>
  502. <row>
  503. <entry><screen>time_duration td1(hours(1)+nanoseconds(2));
  504. time_duration td2 = td1 - minutes(1);</screen>
  505. </entry>
  506. </row>
  507. <row>
  508. <entry valign="top" morerows="1"><screen>time_duration operator/(int)</screen></entry>
  509. <entry>Divide the length of a duration by an integer value. Discards any remainder.</entry>
  510. </row>
  511. <row>
  512. <entry><screen>hours(3)/2 == time_duration(1,30,0);
  513. nanosecond(3)/2 == nanosecond(1);</screen>
  514. </entry>
  515. </row>
  516. <row>
  517. <entry valign="top" morerows="1"><screen>time_duration operator*(int)</screen></entry>
  518. <entry>Multiply the length of a duration by an integer value.</entry>
  519. </row>
  520. <row>
  521. <entry><screen>hours(3)*2 == hours(6);</screen></entry>
  522. </row>
  523. </tbody>
  524. </tgroup>
  525. </informaltable>
  526. </para>
  527. <anchor id="time_duration_struct_tm" />
  528. <bridgehead renderas="sect3">Struct tm, time_t, and FILETIME Functions</bridgehead>
  529. <para>Function for converting a time_duration to a <code>tm</code> struct is provided.</para>
  530. <informaltable frame="all">
  531. <tgroup cols="2">
  532. <thead>
  533. <row>
  534. <entry valign="top" morerows="1">Syntax</entry>
  535. <entry>Description</entry>
  536. </row>
  537. <row>
  538. <entry>Example</entry>
  539. </row>
  540. </thead>
  541. <tbody>
  542. <row>
  543. <entry valign="top" morerows="1"><screen>tm to_tm(time_duration)</screen></entry>
  544. <entry>A function for converting a <code>time_duration</code> object to a <code>tm</code> struct. The fields: <code>tm_year</code>, <code>tm_mon</code>, <code>tm_mday</code>, <code>tm_wday</code>, <code>tm_yday</code> are set to zero. The <code>tm_isdst</code> field is set to -1.</entry>
  545. </row>
  546. <row>
  547. <entry><screen>time_duration td(1,2,3);
  548. tm td_tm = to_tm(td);
  549. /* tm_year => 0
  550. tm_mon => 0
  551. tm_mday => 0
  552. tm_wday => 0
  553. tm_yday => 0
  554. tm_hour => 1
  555. tm_min => 2
  556. tm_sec => 3
  557. tm_isddst => -1 */</screen>
  558. </entry>
  559. </row>
  560. </tbody>
  561. </tgroup>
  562. </informaltable>
  563. </section>