5 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_TIME_TRAITS_HPP
12 #define BOOST_ASIO_TIME_TRAITS_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/push_options.hpp>
20 #include <boost/asio/detail/socket_types.hpp> // Must come before posix_time.
22 #include <boost/asio/detail/push_options.hpp>
23 #include <boost/date_time/posix_time/posix_time_types.hpp>
24 #include <boost/asio/detail/pop_options.hpp>
29 /// Time traits suitable for use with the deadline timer.
30 template <typename Time
>
33 /// Time traits specialised for posix_time.
35 struct time_traits
<boost::posix_time::ptime
>
38 typedef boost::posix_time::ptime time_type
;
40 /// The duration type.
41 typedef boost::posix_time::time_duration duration_type
;
43 /// Get the current time.
44 static time_type
now()
46 return boost::posix_time::microsec_clock::universal_time();
49 /// Add a duration to a time.
50 static time_type
add(const time_type
& t
, const duration_type
& d
)
55 /// Subtract one time from another.
56 static duration_type
subtract(const time_type
& t1
, const time_type
& t2
)
61 /// Test whether one time is less than another.
62 static bool less_than(const time_type
& t1
, const time_type
& t2
)
67 /// Convert to POSIX duration type.
68 static boost::posix_time::time_duration
to_posix_duration(
69 const duration_type
& d
)
78 #include <boost/asio/detail/pop_options.hpp>
80 #endif // BOOST_ASIO_TIME_TRAITS_HPP