File indexing completed on 2025-09-15 08:30:00
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_NO_DEPRECATED)
0021
0022 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \
0023 || defined(GENERATING_DOCUMENTATION)
0024
0025 #include <boost/date_time/posix_time/posix_time_types.hpp>
0026
0027 #include <boost/asio/detail/push_options.hpp>
0028
0029 namespace boost {
0030 namespace asio {
0031
0032
0033 template <typename Time>
0034 struct time_traits;
0035
0036
0037 template <>
0038 struct time_traits<boost::posix_time::ptime>
0039 {
0040
0041 typedef boost::posix_time::ptime time_type;
0042
0043
0044 typedef boost::posix_time::time_duration duration_type;
0045
0046
0047 static time_type now()
0048 {
0049 #if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
0050 return boost::posix_time::microsec_clock::universal_time();
0051 #else
0052 return boost::posix_time::second_clock::universal_time();
0053 #endif
0054 }
0055
0056
0057 static time_type add(const time_type& t, const duration_type& d)
0058 {
0059 return t + d;
0060 }
0061
0062
0063 static duration_type subtract(const time_type& t1, const time_type& t2)
0064 {
0065 return t1 - t2;
0066 }
0067
0068
0069 static bool less_than(const time_type& t1, const time_type& t2)
0070 {
0071 return t1 < t2;
0072 }
0073
0074
0075 static boost::posix_time::time_duration to_posix_duration(
0076 const duration_type& d)
0077 {
0078 return d;
0079 }
0080 };
0081
0082 }
0083 }
0084
0085 #include <boost/asio/detail/pop_options.hpp>
0086
0087 #endif
0088
0089
0090 #endif
0091
0092 #endif