mirror of
https://github.com/boostorg/date_time.git
synced 2026-01-28 07:02:19 +00:00
41 lines
1.8 KiB
HTML
41 lines
1.8 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
|
<title>Example Documentation</title>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
|
</head><body bgcolor="#ffffff">
|
|
<!-- Generated by Doxygen 1.2.17 -->
|
|
<hr><h1>time_math.cpp</h1> Various types of calculations with times and time durations.
|
|
<p>
|
|
<div class="fragment"><pre><font class="comment">//Some simple examples of constructing and calculating with times</font>
|
|
<font class="comment">//Output:</font>
|
|
<font class="comment">//2002-Feb-01 00:00:00 - 2002-Feb-01 05:04:02.001000000 = -5:04:02.001000000</font>
|
|
|
|
<font class="preprocessor">#include "boost/date_time/posix_time/posix_time.hpp"</font>
|
|
<font class="preprocessor">#include <iostream></font>
|
|
|
|
<font class="keywordtype">int</font>
|
|
main()
|
|
{
|
|
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::posix_time;
|
|
using namespace boost::gregorian;
|
|
|
|
date d(2002,Feb,1); <font class="comment">//an arbitrary date</font>
|
|
<font class="comment">//construct a time by adding up some durations durations</font>
|
|
ptime t1(d, hours(5)+minutes(4)+seconds(2)+millisec(1));
|
|
<font class="comment">//construct a new time by subtracting some times</font>
|
|
ptime t2 = t1 - hours(5)- minutes(4)- seconds(2)- millisec(1);
|
|
<font class="comment">//construct a duration by taking the difference between times</font>
|
|
time_duration td = t2 - t1;
|
|
|
|
std::cout << to_simple_string(t2) << " - "
|
|
<< to_simple_string(t1) << " = "
|
|
<< to_simple_string(td) << std::endl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
</pre></div><hr><address><small>
|
|
Generated Wed Aug 21 16:54:33 2002 by Doxygen for CrystalClear Software © 2000-2002</small></address>
|
|
</body>
|
|
</html>
|