Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ASIO_TIME_TRAITS_HPP
00012 #define ASIO_TIME_TRAITS_HPP
00013
00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00015 # pragma once
00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
00017
00018 #include "asio/detail/push_options.hpp"
00019
00020 #include "asio/detail/socket_types.hpp"
00021
00022 #include "asio/detail/push_options.hpp"
00023 #include <boost/date_time/posix_time/posix_time_types.hpp>
00024 #include "asio/detail/pop_options.hpp"
00025
00026 namespace asio {
00027
00029 template <typename Time>
00030 struct time_traits;
00031
00033 template <>
00034 struct time_traits<boost::posix_time::ptime>
00035 {
00037 typedef boost::posix_time::ptime time_type;
00038
00040 typedef boost::posix_time::time_duration duration_type;
00041
00043 static time_type now()
00044 {
00045 return boost::posix_time::microsec_clock::universal_time();
00046 }
00047
00049 static time_type add(const time_type& t, const duration_type& d)
00050 {
00051 return t + d;
00052 }
00053
00055 static duration_type subtract(const time_type& t1, const time_type& t2)
00056 {
00057 return t1 - t2;
00058 }
00059
00061 static bool less_than(const time_type& t1, const time_type& t2)
00062 {
00063 return t1 < t2;
00064 }
00065
00067 static boost::posix_time::time_duration to_posix_duration(
00068 const duration_type& d)
00069 {
00070 return d;
00071 }
00072 };
00073
00074 }
00075
00076 #include "asio/detail/pop_options.hpp"
00077
00078 #endif // ASIO_TIME_TRAITS_HPP