File indexing completed on 2025-01-18 09:29:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_TIME_TRAITS_HPP
0012 #define BOOST_ASIO_TIME_TRAITS_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/socket_types.hpp> // Must come before posix_time.
0019
0020 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \
0021 || defined(GENERATING_DOCUMENTATION)
0022
0023 #include <boost/date_time/posix_time/posix_time_types.hpp>
0024
0025 #include <boost/asio/detail/push_options.hpp>
0026
0027 namespace boost {
0028 namespace asio {
0029
0030
0031 template <typename Time>
0032 struct time_traits;
0033
0034
0035 template <>
0036 struct time_traits<boost::posix_time::ptime>
0037 {
0038
0039 typedef boost::posix_time::ptime time_type;
0040
0041
0042 typedef boost::posix_time::time_duration duration_type;
0043
0044
0045 static time_type now()
0046 {
0047 #if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
0048 return boost::posix_time::microsec_clock::universal_time();
0049 #else
0050 return boost::posix_time::second_clock::universal_time();
0051 #endif
0052 }
0053
0054
0055 static time_type add(const time_type& t, const duration_type& d)
0056 {
0057 return t + d;
0058 }
0059
0060
0061 static duration_type subtract(const time_type& t1, const time_type& t2)
0062 {
0063 return t1 - t2;
0064 }
0065
0066
0067 static bool less_than(const time_type& t1, const time_type& t2)
0068 {
0069 return t1 < t2;
0070 }
0071
0072
0073 static boost::posix_time::time_duration to_posix_duration(
0074 const duration_type& d)
0075 {
0076 return d;
0077 }
0078 };
0079
0080 }
0081 }
0082
0083 #include <boost/asio/detail/pop_options.hpp>
0084
0085 #endif
0086
0087
0088 #endif