]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/date_time/example/posix_time/time_math.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / date_time / example / posix_time / time_math.cpp
1 /* Some simple examples of constructing and calculating with times
2 * Output:
3 * 2002-Feb-01 00:00:00 - 2002-Feb-01 05:04:02.001000000 = -5:04:02.001000000
4 */
5
6 #include "boost/date_time/posix_time/posix_time.hpp"
7 #include <iostream>
8
9 int
10 main()
11 {
12 using namespace boost::posix_time;
13 using namespace boost::gregorian;
14
15 date d(2002,Feb,1); //an arbitrary date
16 //construct a time by adding up some durations
17 ptime t1(d, hours(5)+minutes(4)+seconds(2)+milliseconds(1));
18 //construct a new time by subtracting some times
19 ptime t2 = t1 - hours(5)- minutes(4)- seconds(2)- milliseconds(1);
20 //construct a duration by taking the difference between times
21 time_duration td = t2 - t1;
22
23 std::cout << to_simple_string(t2) << " - "
24 << to_simple_string(t1) << " = "
25 << to_simple_string(td) << std::endl;
26
27 return 0;
28 }
29
30 /* Copyright 2001-2004: CrystalClear Software, Inc
31 * http://www.crystalclearsoftware.com
32 *
33 * Subject to the Boost Software License, Version 1.0.
34 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
35 */
36