File indexing completed on 2025-01-18 09:30:36
0001 #ifndef POSIX_TIME_CONFIG_HPP___
0002 #define POSIX_TIME_CONFIG_HPP___
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <cstdlib> //for MCW 7.2 std::abs(long long)
0013 #include <boost/limits.hpp>
0014 #include <boost/cstdint.hpp>
0015 #include <boost/config/no_tr1/cmath.hpp>
0016 #include <boost/date_time/time_duration.hpp>
0017 #include <boost/date_time/time_resolution_traits.hpp>
0018 #include <boost/date_time/gregorian/gregorian_types.hpp>
0019 #include <boost/date_time/wrapping_int.hpp>
0020 #include <boost/date_time/compiler_config.hpp>
0021
0022 namespace boost {
0023 namespace posix_time {
0024
0025
0026 #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
0027
0028 #define BOOST_DATE_TIME_HAS_NANOSECONDS
0029 typedef date_time::time_resolution_traits<boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::nano,
0030 1000000000, 9 > time_res_traits;
0031 #else
0032
0033 #undef BOOST_DATE_TIME_HAS_NANOSECONDS
0034 typedef date_time::time_resolution_traits<
0035 boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::micro,
0036 1000000, 6 > time_res_traits;
0037
0038 #endif
0039
0040
0041
0042
0043
0044 class BOOST_SYMBOL_VISIBLE time_duration :
0045 public date_time::time_duration<time_duration, time_res_traits>
0046 {
0047 public:
0048 typedef time_res_traits rep_type;
0049 typedef time_res_traits::day_type day_type;
0050 typedef time_res_traits::hour_type hour_type;
0051 typedef time_res_traits::min_type min_type;
0052 typedef time_res_traits::sec_type sec_type;
0053 typedef time_res_traits::fractional_seconds_type fractional_seconds_type;
0054 typedef time_res_traits::tick_type tick_type;
0055 typedef time_res_traits::impl_type impl_type;
0056 BOOST_CXX14_CONSTEXPR time_duration(hour_type hour,
0057 min_type min,
0058 sec_type sec,
0059 fractional_seconds_type fs=0) :
0060 date_time::time_duration<time_duration, time_res_traits>(hour,min,sec,fs)
0061 {}
0062 BOOST_CXX14_CONSTEXPR time_duration() :
0063 date_time::time_duration<time_duration, time_res_traits>(0,0,0)
0064 {}
0065
0066 BOOST_CXX14_CONSTEXPR time_duration(boost::date_time::special_values sv) :
0067 date_time::time_duration<time_duration, time_res_traits>(sv)
0068 {}
0069
0070 friend class date_time::time_duration<time_duration, time_res_traits>;
0071 protected:
0072 BOOST_CXX14_CONSTEXPR explicit time_duration(impl_type tick_count) :
0073 date_time::time_duration<time_duration, time_res_traits>(tick_count)
0074 {}
0075 };
0076
0077 #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
0078
0079
0080 struct simple_time_rep
0081 {
0082 typedef gregorian::date date_type;
0083 typedef time_duration time_duration_type;
0084 BOOST_CXX14_CONSTEXPR simple_time_rep(date_type d, time_duration_type tod) :
0085 day(d),
0086 time_of_day(tod)
0087 {
0088
0089 if(!day.is_special() && !time_of_day.is_special()){
0090 if(time_of_day >= time_duration_type(24,0,0)) {
0091 while(time_of_day >= time_duration_type(24,0,0)) {
0092 day += date_type::duration_type(1);
0093 time_of_day -= time_duration_type(24,0,0);
0094 }
0095 }
0096 else if(time_of_day.is_negative()) {
0097 while(time_of_day.is_negative()) {
0098 day -= date_type::duration_type(1);
0099 time_of_day += time_duration_type(24,0,0);
0100 }
0101 }
0102 }
0103 }
0104 date_type day;
0105 time_duration_type time_of_day;
0106 BOOST_CXX14_CONSTEXPR bool is_special()const
0107 {
0108 return(is_pos_infinity() || is_neg_infinity() || is_not_a_date_time());
0109 }
0110 BOOST_CXX14_CONSTEXPR bool is_pos_infinity()const
0111 {
0112 return(day.is_pos_infinity() || time_of_day.is_pos_infinity());
0113 }
0114 BOOST_CXX14_CONSTEXPR bool is_neg_infinity()const
0115 {
0116 return(day.is_neg_infinity() || time_of_day.is_neg_infinity());
0117 }
0118 BOOST_CXX14_CONSTEXPR bool is_not_a_date_time()const
0119 {
0120 return(day.is_not_a_date() || time_of_day.is_not_a_date_time());
0121 }
0122 };
0123
0124 class BOOST_SYMBOL_VISIBLE posix_time_system_config
0125 {
0126 public:
0127 typedef simple_time_rep time_rep_type;
0128 typedef gregorian::date date_type;
0129 typedef gregorian::date_duration date_duration_type;
0130 typedef time_duration time_duration_type;
0131 typedef time_res_traits::tick_type int_type;
0132 typedef time_res_traits resolution_traits;
0133 #if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT))
0134 #else
0135 BOOST_STATIC_CONSTANT(boost::int64_t, tick_per_second = 1000000000);
0136 #endif
0137 };
0138
0139 #else
0140
0141 class millisec_posix_time_system_config
0142 {
0143 public:
0144 typedef boost::int64_t time_rep_type;
0145
0146 typedef gregorian::date date_type;
0147 typedef gregorian::date_duration date_duration_type;
0148 typedef time_duration time_duration_type;
0149 typedef time_res_traits::tick_type int_type;
0150 typedef time_res_traits::impl_type impl_type;
0151 typedef time_res_traits resolution_traits;
0152 #if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT))
0153 #else
0154 BOOST_STATIC_CONSTANT(boost::int64_t, tick_per_second = 1000000);
0155 #endif
0156 };
0157
0158 #endif
0159
0160 } }
0161
0162
0163 #endif
0164
0165