File indexing completed on 2025-01-30 09:35:18
0001 #ifndef GREG_DURATION_HPP___
0002 #define GREG_DURATION_HPP___
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <boost/date_time/compiler_config.hpp>
0013 #include <boost/date_time/date_duration.hpp>
0014 #include <boost/date_time/int_adapter.hpp>
0015 #include <boost/date_time/special_defs.hpp>
0016
0017 namespace boost {
0018 namespace gregorian {
0019
0020
0021 typedef boost::date_time::duration_traits_adapted date_duration_rep;
0022
0023
0024
0025
0026 class BOOST_SYMBOL_VISIBLE date_duration :
0027 public boost::date_time::date_duration< date_duration_rep >
0028 {
0029 typedef boost::date_time::date_duration< date_duration_rep > base_type;
0030
0031 public:
0032 typedef base_type::duration_rep duration_rep;
0033
0034
0035 BOOST_CXX14_CONSTEXPR explicit
0036 date_duration(duration_rep day_count = 0) : base_type(day_count) {}
0037
0038
0039 BOOST_CXX14_CONSTEXPR
0040 date_duration(date_time::special_values sv) : base_type(sv) {}
0041
0042
0043 BOOST_CXX14_CONSTEXPR
0044 date_duration(const base_type& other) : base_type(other)
0045 {}
0046
0047
0048
0049
0050
0051 BOOST_CXX14_CONSTEXPR bool operator== (const date_duration& rhs) const
0052 {
0053 return base_type::operator== (rhs);
0054 }
0055 BOOST_CXX14_CONSTEXPR bool operator!= (const date_duration& rhs) const
0056 {
0057 return !operator== (rhs);
0058 }
0059 BOOST_CXX14_CONSTEXPR bool operator< (const date_duration& rhs) const
0060 {
0061 return base_type::operator< (rhs);
0062 }
0063 BOOST_CXX14_CONSTEXPR bool operator> (const date_duration& rhs) const
0064 {
0065 return !(base_type::operator< (rhs) || base_type::operator== (rhs));
0066 }
0067 BOOST_CXX14_CONSTEXPR bool operator<= (const date_duration& rhs) const
0068 {
0069 return (base_type::operator< (rhs) || base_type::operator== (rhs));
0070 }
0071 BOOST_CXX14_CONSTEXPR bool operator>= (const date_duration& rhs) const
0072 {
0073 return !base_type::operator< (rhs);
0074 }
0075
0076
0077 BOOST_CXX14_CONSTEXPR date_duration& operator-= (const date_duration& rhs)
0078 {
0079 base_type::operator-= (rhs);
0080 return *this;
0081 }
0082
0083 BOOST_CXX14_CONSTEXPR friend
0084 date_duration operator- (date_duration rhs, date_duration const& lhs);
0085
0086
0087 BOOST_CXX14_CONSTEXPR date_duration& operator+= (const date_duration& rhs)
0088 {
0089 base_type::operator+= (rhs);
0090 return *this;
0091 }
0092
0093 BOOST_CXX14_CONSTEXPR friend
0094 date_duration operator+ (date_duration rhs, date_duration const& lhs);
0095
0096
0097 BOOST_CXX14_CONSTEXPR date_duration operator- ()const
0098 {
0099 return date_duration(get_rep() * (-1));
0100 }
0101
0102
0103 BOOST_CXX14_CONSTEXPR date_duration& operator/= (int divisor)
0104 {
0105 base_type::operator/= (divisor);
0106 return *this;
0107 }
0108
0109 BOOST_CXX14_CONSTEXPR friend date_duration operator/ (date_duration rhs, int lhs);
0110
0111
0112 static BOOST_CXX14_CONSTEXPR date_duration unit()
0113 {
0114 return date_duration(base_type::unit().get_rep());
0115 }
0116 };
0117
0118 inline BOOST_CXX14_CONSTEXPR
0119 date_duration operator- (date_duration rhs, date_duration const& lhs)
0120 {
0121 rhs -= lhs;
0122 return rhs;
0123 }
0124
0125 inline BOOST_CXX14_CONSTEXPR
0126 date_duration operator+ (date_duration rhs, date_duration const& lhs)
0127 {
0128 rhs += lhs;
0129 return rhs;
0130 }
0131
0132 inline BOOST_CXX14_CONSTEXPR date_duration operator/ (date_duration rhs, int lhs)
0133 {
0134 rhs /= lhs;
0135 return rhs;
0136 }
0137
0138
0139 typedef date_duration days;
0140
0141 } }
0142
0143 #if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
0144 #include <boost/date_time/date_duration_types.hpp>
0145 #endif
0146
0147 #endif