fix doc example typo
[boost.git] / boost / asio / time_traits.hpp
blob097ece43d30d26a33a1e72a593867c7d68714aff
1 //
2 // time_traits.hpp
3 // ~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
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)
9 //
11 #ifndef BOOST_ASIO_TIME_TRAITS_HPP
12 #define BOOST_ASIO_TIME_TRAITS_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
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>
26 namespace boost {
27 namespace asio {
29 /// Time traits suitable for use with the deadline timer.
30 template <typename Time>
31 struct time_traits;
33 /// Time traits specialised for posix_time.
34 template <>
35 struct time_traits<boost::posix_time::ptime>
37 /// The time type.
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)
52 return t + d;
55 /// Subtract one time from another.
56 static duration_type subtract(const time_type& t1, const time_type& t2)
58 return t1 - t2;
61 /// Test whether one time is less than another.
62 static bool less_than(const time_type& t1, const time_type& t2)
64 return t1 < t2;
67 /// Convert to POSIX duration type.
68 static boost::posix_time::time_duration to_posix_duration(
69 const duration_type& d)
71 return d;
75 } // namespace asio
76 } // namespace boost
78 #include <boost/asio/detail/pop_options.hpp>
80 #endif // BOOST_ASIO_TIME_TRAITS_HPP