File indexing completed on 2025-01-18 09:30:39
0001 #ifndef DATE_TIME_TIME_HPP___
0002 #define DATE_TIME_TIME_HPP___
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <string>
0017 #include <boost/operators.hpp>
0018 #include <boost/date_time/time_defs.hpp>
0019 #include <boost/date_time/special_defs.hpp>
0020
0021 namespace boost {
0022 namespace date_time {
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 template <class T, class time_system>
0046 class base_time : private
0047 boost::less_than_comparable<T
0048 , boost::equality_comparable<T
0049 > >
0050 {
0051 public:
0052
0053 typedef void _is_boost_date_time_time_point;
0054 typedef T time_type;
0055 typedef typename time_system::time_rep_type time_rep_type;
0056 typedef typename time_system::date_type date_type;
0057 typedef typename time_system::date_duration_type date_duration_type;
0058 typedef typename time_system::time_duration_type time_duration_type;
0059
0060
0061 BOOST_CXX14_CONSTEXPR
0062 base_time(const date_type& day,
0063 const time_duration_type& td,
0064 dst_flags dst=not_dst) :
0065 time_(time_system::get_time_rep(day, td, dst))
0066 {}
0067 BOOST_CXX14_CONSTEXPR
0068 base_time(special_values sv) :
0069 time_(time_system::get_time_rep(sv))
0070 {}
0071 BOOST_CXX14_CONSTEXPR
0072 base_time(const time_rep_type& rhs) :
0073 time_(rhs)
0074 {}
0075 BOOST_CXX14_CONSTEXPR
0076 date_type date() const
0077 {
0078 return time_system::get_date(time_);
0079 }
0080 BOOST_CXX14_CONSTEXPR
0081 time_duration_type time_of_day() const
0082 {
0083 return time_system::get_time_of_day(time_);
0084 }
0085
0086
0087
0088 std::string zone_name(bool =false) const
0089 {
0090 return time_system::zone_name(time_);
0091 }
0092
0093
0094
0095 std::string zone_abbrev(bool =false) const
0096 {
0097 return time_system::zone_name(time_);
0098 }
0099
0100 std::string zone_as_posix_string() const
0101 {
0102 return std::string();
0103 }
0104
0105
0106 BOOST_CXX14_CONSTEXPR
0107 bool is_not_a_date_time() const
0108 {
0109 return time_.is_not_a_date_time();
0110 }
0111
0112 BOOST_CXX14_CONSTEXPR
0113 bool is_infinity() const
0114 {
0115 return (is_pos_infinity() || is_neg_infinity());
0116 }
0117
0118 BOOST_CXX14_CONSTEXPR
0119 bool is_pos_infinity() const
0120 {
0121 return time_.is_pos_infinity();
0122 }
0123
0124 BOOST_CXX14_CONSTEXPR
0125 bool is_neg_infinity() const
0126 {
0127 return time_.is_neg_infinity();
0128 }
0129
0130 BOOST_CXX14_CONSTEXPR
0131 bool is_special() const
0132 {
0133 return(is_not_a_date_time() || is_infinity());
0134 }
0135
0136 BOOST_CXX14_CONSTEXPR
0137 bool operator==(const time_type& rhs) const
0138 {
0139 return time_system::is_equal(time_,rhs.time_);
0140 }
0141
0142 BOOST_CXX14_CONSTEXPR
0143 bool operator<(const time_type& rhs) const
0144 {
0145 return time_system::is_less(time_,rhs.time_);
0146 }
0147
0148 BOOST_CXX14_CONSTEXPR
0149 time_duration_type operator-(const time_type& rhs) const
0150 {
0151 return time_system::subtract_times(time_, rhs.time_);
0152 }
0153
0154 BOOST_CXX14_CONSTEXPR
0155 time_type operator+(const date_duration_type& dd) const
0156 {
0157 return time_system::add_days(time_, dd);
0158 }
0159 BOOST_CXX14_CONSTEXPR
0160 time_type operator+=(const date_duration_type& dd)
0161 {
0162 time_ = (time_system::get_time_rep(date() + dd, time_of_day()));
0163 return time_type(time_);
0164 }
0165
0166 BOOST_CXX14_CONSTEXPR
0167 time_type operator-(const date_duration_type& dd) const
0168 {
0169 return time_system::subtract_days(time_, dd);
0170 }
0171 BOOST_CXX14_CONSTEXPR
0172 time_type operator-=(const date_duration_type& dd)
0173 {
0174 time_ = (time_system::get_time_rep(date() - dd, time_of_day()));
0175 return time_type(time_);
0176 }
0177
0178 BOOST_CXX14_CONSTEXPR
0179 time_type operator+(const time_duration_type& td) const
0180 {
0181 return time_type(time_system::add_time_duration(time_, td));
0182 }
0183 BOOST_CXX14_CONSTEXPR
0184 time_type operator+=(const time_duration_type& td)
0185 {
0186 time_ = time_system::add_time_duration(time_,td);
0187 return time_type(time_);
0188 }
0189
0190 BOOST_CXX14_CONSTEXPR
0191 time_type operator-(const time_duration_type& rhs) const
0192 {
0193 return time_system::subtract_time_duration(time_, rhs);
0194 }
0195 BOOST_CXX14_CONSTEXPR
0196 time_type operator-=(const time_duration_type& td)
0197 {
0198 time_ = time_system::subtract_time_duration(time_, td);
0199 return time_type(time_);
0200 }
0201
0202 protected:
0203 time_rep_type time_;
0204 };
0205
0206
0207
0208
0209
0210 } }
0211
0212
0213 #endif
0214