]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/date_time/example/posix_time/time_math.cpp
1 /* Some simple examples of constructing and calculating with times
3 * 2002-Feb-01 00:00:00 - 2002-Feb-01 05:04:02.001000000 = -5:04:02.001000000
6 #include "boost/date_time/posix_time/posix_time.hpp"
12 using namespace boost::posix_time
;
13 using namespace boost::gregorian
;
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
;
23 std::cout
<< to_simple_string(t2
) << " - "
24 << to_simple_string(t1
) << " = "
25 << to_simple_string(td
) << std::endl
;
30 /* Copyright 2001-2004: CrystalClear Software, Inc
31 * http://www.crystalclearsoftware.com
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)