mirror of
https://github.com/boostorg/date_time.git
synced 2026-01-19 04:12:07 +00:00
* initial set of core changes for constexpr support (issue #123) * fixes for constexpr core support based on ci failures (issue #123) * drive by fix for gcc9.2 warning on polymorphic exception * fixes for constexpr core support based on for cpp11 and cpp14 build variants (issue #123) * more fixes for constexpr core support (issue #123) - also fix for issue #124 * next round of changes for constexpr core support (issue #123) * fix last msvc regression for constexpr core * driveby fix to remove detail include * 3rd round of changes for constexpr * yet another msvc fix for cpp14 * minor doc fix for issue #127 - tm_isddst -> tm_isdst * minor doc fix for issue #127 - tm_isddst -> tm_isdst * push constexpr deep into the library including date, ptime (issue #123) * push constexpr deep into the library including date, ptime (issue #123) * fix latests regressions from constexpr changes in older gcc
This commit is contained in:
@@ -22,10 +22,10 @@ int main()
|
||||
tz_database tz_db;
|
||||
try {
|
||||
tz_db.load_from_file("../../data/date_time_zonespec.csv");
|
||||
}catch(data_not_accessible dna) {
|
||||
}catch(const data_not_accessible& dna) {
|
||||
std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}catch(bad_field_count bfc) {
|
||||
}catch(const bad_field_count& bfc) {
|
||||
std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -43,21 +43,25 @@ namespace CV {
|
||||
public:
|
||||
typedef typename value_policies::value_type value_type;
|
||||
// typedef except_type exception_type;
|
||||
constrained_value(value_type value) : value_((min)())
|
||||
BOOST_CXX14_CONSTEXPR constrained_value(value_type value) : value_((min)())
|
||||
{
|
||||
assign(value);
|
||||
}
|
||||
constrained_value& operator=(value_type v)
|
||||
BOOST_CXX14_CONSTEXPR constrained_value& operator=(value_type v)
|
||||
{
|
||||
assign(v);
|
||||
return *this;
|
||||
}
|
||||
//! Return the max allowed value (traits method)
|
||||
static value_type max BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::max)();}
|
||||
static BOOST_CONSTEXPR_OR_CONST value_type
|
||||
max BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::max)();}
|
||||
|
||||
//! Return the min allowed value (traits method)
|
||||
static value_type min BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::min)();}
|
||||
static BOOST_CONSTEXPR_OR_CONST value_type
|
||||
min BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::min)();}
|
||||
|
||||
//! Coerce into the representation type
|
||||
operator value_type() const {return value_;}
|
||||
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
|
||||
protected:
|
||||
value_type value_;
|
||||
private:
|
||||
@@ -103,8 +107,12 @@ namespace CV {
|
||||
|
||||
public:
|
||||
typedef rep_type value_type;
|
||||
static rep_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return min_value; }
|
||||
static rep_type max BOOST_PREVENT_MACRO_SUBSTITUTION () { return max_value; }
|
||||
static BOOST_CONSTEXPR_OR_CONST rep_type
|
||||
min BOOST_PREVENT_MACRO_SUBSTITUTION () { return min_value; }
|
||||
|
||||
static BOOST_CONSTEXPR_OR_CONST rep_type
|
||||
max BOOST_PREVENT_MACRO_SUBSTITUTION () { return max_value; }
|
||||
|
||||
static void on_error(rep_type, rep_type, violation_enum)
|
||||
{
|
||||
boost::throw_exception(actual_exception_type());
|
||||
|
||||
@@ -68,76 +68,76 @@ namespace date_time {
|
||||
typedef typename calendar::date_rep_type date_rep_type;
|
||||
typedef typename calendar::date_int_type date_int_type;
|
||||
typedef typename calendar::day_of_week_type day_of_week_type;
|
||||
date(year_type y, month_type m, day_type d)
|
||||
BOOST_CXX14_CONSTEXPR date(year_type y, month_type m, day_type d)
|
||||
: days_(calendar::day_number(ymd_type(y, m, d)))
|
||||
{}
|
||||
date(const ymd_type& ymd)
|
||||
BOOST_CXX14_CONSTEXPR date(const ymd_type& ymd)
|
||||
: days_(calendar::day_number(ymd))
|
||||
{}
|
||||
//let the compiler write copy, assignment, and destructor
|
||||
year_type year() const
|
||||
BOOST_CXX14_CONSTEXPR year_type year() const
|
||||
{
|
||||
ymd_type ymd = calendar::from_day_number(days_);
|
||||
return ymd.year;
|
||||
}
|
||||
month_type month() const
|
||||
BOOST_CXX14_CONSTEXPR month_type month() const
|
||||
{
|
||||
ymd_type ymd = calendar::from_day_number(days_);
|
||||
return ymd.month;
|
||||
}
|
||||
day_type day() const
|
||||
BOOST_CXX14_CONSTEXPR day_type day() const
|
||||
{
|
||||
ymd_type ymd = calendar::from_day_number(days_);
|
||||
return ymd.day;
|
||||
}
|
||||
day_of_week_type day_of_week() const
|
||||
BOOST_CXX14_CONSTEXPR day_of_week_type day_of_week() const
|
||||
{
|
||||
ymd_type ymd = calendar::from_day_number(days_);
|
||||
return calendar::day_of_week(ymd);
|
||||
}
|
||||
ymd_type year_month_day() const
|
||||
BOOST_CXX14_CONSTEXPR ymd_type year_month_day() const
|
||||
{
|
||||
return calendar::from_day_number(days_);
|
||||
}
|
||||
bool operator<(const date_type& rhs) const
|
||||
BOOST_CONSTEXPR bool operator<(const date_type& rhs) const
|
||||
{
|
||||
return days_ < rhs.days_;
|
||||
}
|
||||
bool operator==(const date_type& rhs) const
|
||||
BOOST_CONSTEXPR bool operator==(const date_type& rhs) const
|
||||
{
|
||||
return days_ == rhs.days_;
|
||||
}
|
||||
//! check to see if date is a special value
|
||||
bool is_special()const
|
||||
BOOST_CONSTEXPR bool is_special()const
|
||||
{
|
||||
return(is_not_a_date() || is_infinity());
|
||||
}
|
||||
//! check to see if date is not a value
|
||||
bool is_not_a_date() const
|
||||
BOOST_CONSTEXPR bool is_not_a_date() const
|
||||
{
|
||||
return traits_type::is_not_a_number(days_);
|
||||
}
|
||||
//! check to see if date is one of the infinity values
|
||||
bool is_infinity() const
|
||||
BOOST_CONSTEXPR bool is_infinity() const
|
||||
{
|
||||
return traits_type::is_inf(days_);
|
||||
}
|
||||
//! check to see if date is greater than all possible dates
|
||||
bool is_pos_infinity() const
|
||||
BOOST_CONSTEXPR bool is_pos_infinity() const
|
||||
{
|
||||
return traits_type::is_pos_inf(days_);
|
||||
}
|
||||
//! check to see if date is greater than all possible dates
|
||||
bool is_neg_infinity() const
|
||||
BOOST_CONSTEXPR bool is_neg_infinity() const
|
||||
{
|
||||
return traits_type::is_neg_inf(days_);
|
||||
}
|
||||
//! return as a special value or a not_special if a normal date
|
||||
special_values as_special() const
|
||||
BOOST_CXX14_CONSTEXPR special_values as_special() const
|
||||
{
|
||||
return traits_type::to_special(days_);
|
||||
}
|
||||
duration_type operator-(const date_type& d) const
|
||||
BOOST_CXX14_CONSTEXPR duration_type operator-(const date_type& d) const
|
||||
{
|
||||
if (!this->is_special() && !d.is_special())
|
||||
{
|
||||
@@ -154,7 +154,7 @@ namespace date_time {
|
||||
}
|
||||
}
|
||||
|
||||
date_type operator-(const duration_type& dd) const
|
||||
BOOST_CXX14_CONSTEXPR date_type operator-(const duration_type& dd) const
|
||||
{
|
||||
if(dd.is_special())
|
||||
{
|
||||
@@ -162,17 +162,17 @@ namespace date_time {
|
||||
}
|
||||
return date_type(date_rep_type(days_) - static_cast<date_int_type>(dd.days()));
|
||||
}
|
||||
date_type operator-=(const duration_type& dd)
|
||||
BOOST_CXX14_CONSTEXPR date_type operator-=(const duration_type& dd)
|
||||
{
|
||||
*this = *this - dd;
|
||||
return date_type(days_);
|
||||
}
|
||||
date_rep_type day_count() const
|
||||
BOOST_CONSTEXPR date_rep_type day_count() const
|
||||
{
|
||||
return days_;
|
||||
}
|
||||
//allow internal access from operators
|
||||
date_type operator+(const duration_type& dd) const
|
||||
BOOST_CXX14_CONSTEXPR date_type operator+(const duration_type& dd) const
|
||||
{
|
||||
if(dd.is_special())
|
||||
{
|
||||
@@ -180,7 +180,7 @@ namespace date_time {
|
||||
}
|
||||
return date_type(date_rep_type(days_) + static_cast<date_int_type>(dd.days()));
|
||||
}
|
||||
date_type operator+=(const duration_type& dd)
|
||||
BOOST_CXX14_CONSTEXPR date_type operator+=(const duration_type& dd)
|
||||
{
|
||||
*this = *this + dd;
|
||||
return date_type(days_);
|
||||
@@ -192,8 +192,8 @@ namespace date_time {
|
||||
dates. It is not exposed to users since that would require class
|
||||
users to understand the inner workings of the date class.
|
||||
*/
|
||||
explicit date(date_int_type days) : days_(days) {}
|
||||
explicit date(date_rep_type days) : days_(days.as_number()) {}
|
||||
BOOST_CONSTEXPR explicit date(date_int_type days) : days_(days) {}
|
||||
BOOST_CXX14_CONSTEXPR explicit date(date_rep_type days) : days_(days.as_number()) {}
|
||||
date_int_type days_;
|
||||
|
||||
};
|
||||
|
||||
@@ -33,50 +33,50 @@ namespace date_time {
|
||||
typedef typename duration_rep_traits::impl_type duration_rep;
|
||||
|
||||
//! Construct from a day count
|
||||
explicit date_duration(duration_rep day_count) : days_(day_count) {}
|
||||
BOOST_CXX14_CONSTEXPR explicit date_duration(duration_rep day_count) : days_(day_count) {}
|
||||
|
||||
/*! construct from special_values - only works when
|
||||
* instantiated with duration_traits_adapted */
|
||||
date_duration(special_values sv) :
|
||||
BOOST_CXX14_CONSTEXPR date_duration(special_values sv) :
|
||||
days_(duration_rep::from_special(sv))
|
||||
{}
|
||||
|
||||
// copy constructor required for addable<> & subtractable<>
|
||||
//! Construct from another date_duration (Copy Constructor)
|
||||
date_duration(const date_duration<duration_rep_traits>& other) :
|
||||
BOOST_CXX14_CONSTEXPR date_duration(const date_duration<duration_rep_traits>& other) :
|
||||
days_(other.days_)
|
||||
{}
|
||||
|
||||
//! returns days_ as it's instantiated type - used for streaming
|
||||
duration_rep get_rep()const
|
||||
BOOST_CXX14_CONSTEXPR duration_rep get_rep()const
|
||||
{
|
||||
return days_;
|
||||
}
|
||||
special_values as_special() const
|
||||
BOOST_CXX14_CONSTEXPR special_values as_special() const
|
||||
{
|
||||
return days_.as_special();
|
||||
}
|
||||
bool is_special()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_special()const
|
||||
{
|
||||
return days_.is_special();
|
||||
}
|
||||
//! returns days as value, not object.
|
||||
duration_rep_type days() const
|
||||
BOOST_CXX14_CONSTEXPR duration_rep_type days() const
|
||||
{
|
||||
return duration_rep_traits::as_number(days_);
|
||||
}
|
||||
//! Returns the smallest duration -- used by to calculate 'end'
|
||||
static date_duration unit()
|
||||
static BOOST_CXX14_CONSTEXPR date_duration unit()
|
||||
{
|
||||
return date_duration<duration_rep_traits>(1);
|
||||
}
|
||||
//! Equality
|
||||
bool operator==(const date_duration& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator==(const date_duration& rhs) const
|
||||
{
|
||||
return days_ == rhs.days_;
|
||||
}
|
||||
//! Less
|
||||
bool operator<(const date_duration& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator<(const date_duration& rhs) const
|
||||
{
|
||||
return days_ < rhs.days_;
|
||||
}
|
||||
@@ -87,33 +87,33 @@ namespace date_time {
|
||||
* so this will not compile */
|
||||
|
||||
//! Subtract another duration -- result is signed
|
||||
date_duration& operator-=(const date_duration& rhs)
|
||||
BOOST_CXX14_CONSTEXPR date_duration& operator-=(const date_duration& rhs)
|
||||
{
|
||||
//days_ -= rhs.days_;
|
||||
days_ = days_ - rhs.days_;
|
||||
return *this;
|
||||
}
|
||||
//! Add a duration -- result is signed
|
||||
date_duration& operator+=(const date_duration& rhs)
|
||||
BOOST_CXX14_CONSTEXPR date_duration& operator+=(const date_duration& rhs)
|
||||
{
|
||||
days_ = days_ + rhs.days_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! unary- Allows for dd = -date_duration(2); -> dd == -2
|
||||
date_duration operator-() const
|
||||
BOOST_CXX14_CONSTEXPR date_duration operator-() const
|
||||
{
|
||||
return date_duration<duration_rep_traits>(get_rep() * (-1));
|
||||
}
|
||||
//! Division operations on a duration with an integer.
|
||||
date_duration& operator/=(int divisor)
|
||||
BOOST_CXX14_CONSTEXPR date_duration& operator/=(int divisor)
|
||||
{
|
||||
days_ = days_ / divisor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! return sign information
|
||||
bool is_negative() const
|
||||
BOOST_CXX14_CONSTEXPR bool is_negative() const
|
||||
{
|
||||
return days_ < 0;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ namespace date_time {
|
||||
{
|
||||
typedef long int_type;
|
||||
typedef long impl_type;
|
||||
static int_type as_number(impl_type i) { return i; }
|
||||
static BOOST_CXX14_CONSTEXPR int_type as_number(impl_type i) { return i; }
|
||||
};
|
||||
|
||||
/*! Struct for instantiating date_duration <b>WITH</b> special values
|
||||
@@ -140,7 +140,7 @@ namespace date_time {
|
||||
{
|
||||
typedef long int_type;
|
||||
typedef boost::date_time::int_adapter<long> impl_type;
|
||||
static int_type as_number(impl_type i) { return i.as_number(); }
|
||||
static BOOST_CXX14_CONSTEXPR int_type as_number(impl_type i) { return i.as_number(); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace date_time {
|
||||
template <class duration_config>
|
||||
class BOOST_SYMBOL_VISIBLE weeks_duration : public date_duration<duration_config> {
|
||||
public:
|
||||
weeks_duration(typename duration_config::impl_type w)
|
||||
BOOST_CXX14_CONSTEXPR weeks_duration(typename duration_config::impl_type w)
|
||||
: date_duration<duration_config>(w * 7) {}
|
||||
weeks_duration(special_values sv)
|
||||
BOOST_CXX14_CONSTEXPR weeks_duration(special_values sv)
|
||||
: date_duration<duration_config>(sv) {}
|
||||
};
|
||||
|
||||
@@ -49,101 +49,101 @@ namespace date_time {
|
||||
typedef months_duration<base_config> months_type;
|
||||
typedef years_duration<base_config> years_type;
|
||||
public:
|
||||
months_duration(int_rep num) : _m(num) {}
|
||||
months_duration(special_values sv) : _m(sv)
|
||||
BOOST_CXX14_CONSTEXPR months_duration(int_rep num) : _m(num) {}
|
||||
BOOST_CXX14_CONSTEXPR months_duration(special_values sv) : _m(sv)
|
||||
{
|
||||
_m = int_rep::from_special(sv);
|
||||
}
|
||||
int_rep number_of_months() const { return _m; }
|
||||
//! returns a negative duration
|
||||
duration_type get_neg_offset(const date_type& d) const
|
||||
BOOST_CXX14_CONSTEXPR duration_type get_neg_offset(const date_type& d) const
|
||||
{
|
||||
month_adjustor_type m_adj(_m.as_number());
|
||||
return duration_type(m_adj.get_neg_offset(d));
|
||||
}
|
||||
duration_type get_offset(const date_type& d) const
|
||||
BOOST_CXX14_CONSTEXPR duration_type get_offset(const date_type& d) const
|
||||
{
|
||||
month_adjustor_type m_adj(_m.as_number());
|
||||
return duration_type(m_adj.get_offset(d));
|
||||
}
|
||||
bool operator==(const months_type& rhs) const
|
||||
BOOST_CONSTEXPR bool operator==(const months_type& rhs) const
|
||||
{
|
||||
return(_m == rhs._m);
|
||||
}
|
||||
bool operator!=(const months_type& rhs) const
|
||||
BOOST_CONSTEXPR bool operator!=(const months_type& rhs) const
|
||||
{
|
||||
return(_m != rhs._m);
|
||||
}
|
||||
months_type operator+(const months_type& rhs)const
|
||||
BOOST_CXX14_CONSTEXPR months_type operator+(const months_type& rhs)const
|
||||
{
|
||||
return months_type(_m + rhs._m);
|
||||
}
|
||||
months_type& operator+=(const months_type& rhs)
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator+=(const months_type& rhs)
|
||||
{
|
||||
_m = _m + rhs._m;
|
||||
return *this;
|
||||
}
|
||||
months_type operator-(const months_type& rhs)const
|
||||
BOOST_CXX14_CONSTEXPR months_type operator-(const months_type& rhs)const
|
||||
{
|
||||
return months_type(_m - rhs._m);
|
||||
}
|
||||
months_type& operator-=(const months_type& rhs)
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator-=(const months_type& rhs)
|
||||
{
|
||||
_m = _m - rhs._m;
|
||||
return *this;
|
||||
}
|
||||
months_type operator*(const int_type rhs)const
|
||||
BOOST_CXX14_CONSTEXPR months_type operator*(const int_type rhs)const
|
||||
{
|
||||
return months_type(_m * rhs);
|
||||
}
|
||||
months_type& operator*=(const int_type rhs)
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator*=(const int_type rhs)
|
||||
{
|
||||
_m = _m * rhs;
|
||||
return *this;
|
||||
}
|
||||
months_type operator/(const int_type rhs)const
|
||||
BOOST_CXX14_CONSTEXPR months_type operator/(const int_type rhs)const
|
||||
{
|
||||
return months_type(_m / rhs);
|
||||
}
|
||||
months_type& operator/=(const int_type rhs)
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator/=(const int_type rhs)
|
||||
{
|
||||
_m = _m / rhs;
|
||||
return *this;
|
||||
}
|
||||
months_type operator+(const years_type& y)const
|
||||
BOOST_CXX14_CONSTEXPR months_type operator+(const years_type& y)const
|
||||
{
|
||||
return months_type(y.number_of_years() * 12 + _m);
|
||||
}
|
||||
months_type& operator+=(const years_type& y)
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator+=(const years_type& y)
|
||||
{
|
||||
_m = y.number_of_years() * 12 + _m;
|
||||
return *this;
|
||||
}
|
||||
months_type operator-(const years_type& y) const
|
||||
BOOST_CXX14_CONSTEXPR months_type operator-(const years_type& y) const
|
||||
{
|
||||
return months_type(_m - y.number_of_years() * 12);
|
||||
}
|
||||
months_type& operator-=(const years_type& y)
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator-=(const years_type& y)
|
||||
{
|
||||
_m = _m - y.number_of_years() * 12;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
friend date_type operator+(const date_type& d, const months_type& m)
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator+(const date_type& d, const months_type& m)
|
||||
{
|
||||
return d + m.get_offset(d);
|
||||
}
|
||||
friend date_type operator+=(date_type& d, const months_type& m)
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator+=(date_type& d, const months_type& m)
|
||||
{
|
||||
return d += m.get_offset(d);
|
||||
}
|
||||
friend date_type operator-(const date_type& d, const months_type& m)
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator-(const date_type& d, const months_type& m)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return d + m.get_neg_offset(d);
|
||||
}
|
||||
friend date_type operator-=(date_type& d, const months_type& m)
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator-=(date_type& d, const months_type& m)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return d += m.get_neg_offset(d);
|
||||
@@ -171,24 +171,24 @@ namespace date_time {
|
||||
typedef years_duration<base_config> years_type;
|
||||
typedef months_duration<base_config> months_type;
|
||||
public:
|
||||
years_duration(int_rep num) : _y(num) {}
|
||||
years_duration(special_values sv) : _y(sv)
|
||||
BOOST_CXX14_CONSTEXPR years_duration(int_rep num) : _y(num) {}
|
||||
BOOST_CXX14_CONSTEXPR years_duration(special_values sv) : _y(sv)
|
||||
{
|
||||
_y = int_rep::from_special(sv);
|
||||
}
|
||||
int_rep number_of_years() const { return _y; }
|
||||
BOOST_CXX14_CONSTEXPR int_rep number_of_years() const { return _y; }
|
||||
//! returns a negative duration
|
||||
duration_type get_neg_offset(const date_type& d) const
|
||||
BOOST_CXX14_CONSTEXPR duration_type get_neg_offset(const date_type& d) const
|
||||
{
|
||||
month_adjustor_type m_adj(_y.as_number() * 12);
|
||||
return duration_type(m_adj.get_neg_offset(d));
|
||||
}
|
||||
duration_type get_offset(const date_type& d) const
|
||||
BOOST_CXX14_CONSTEXPR duration_type get_offset(const date_type& d) const
|
||||
{
|
||||
month_adjustor_type m_adj(_y.as_number() * 12);
|
||||
return duration_type(m_adj.get_offset(d));
|
||||
}
|
||||
bool operator==(const years_type& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator==(const years_type& rhs) const
|
||||
{
|
||||
return(_y == rhs._y);
|
||||
}
|
||||
@@ -196,66 +196,66 @@ namespace date_time {
|
||||
{
|
||||
return(_y != rhs._y);
|
||||
}
|
||||
years_type operator+(const years_type& rhs)const
|
||||
BOOST_CXX14_CONSTEXPR years_type operator+(const years_type& rhs)const
|
||||
{
|
||||
return years_type(_y + rhs._y);
|
||||
}
|
||||
years_type& operator+=(const years_type& rhs)
|
||||
BOOST_CXX14_CONSTEXPR years_type& operator+=(const years_type& rhs)
|
||||
{
|
||||
_y = _y + rhs._y;
|
||||
return *this;
|
||||
}
|
||||
years_type operator-(const years_type& rhs)const
|
||||
BOOST_CXX14_CONSTEXPR years_type operator-(const years_type& rhs)const
|
||||
{
|
||||
return years_type(_y - rhs._y);
|
||||
}
|
||||
years_type& operator-=(const years_type& rhs)
|
||||
BOOST_CXX14_CONSTEXPR years_type& operator-=(const years_type& rhs)
|
||||
{
|
||||
_y = _y - rhs._y;
|
||||
return *this;
|
||||
}
|
||||
years_type operator*(const int_type rhs)const
|
||||
BOOST_CXX14_CONSTEXPR years_type operator*(const int_type rhs)const
|
||||
{
|
||||
return years_type(_y * rhs);
|
||||
}
|
||||
years_type& operator*=(const int_type rhs)
|
||||
BOOST_CXX14_CONSTEXPR years_type& operator*=(const int_type rhs)
|
||||
{
|
||||
_y = _y * rhs;
|
||||
return *this;
|
||||
}
|
||||
years_type operator/(const int_type rhs)const
|
||||
BOOST_CXX14_CONSTEXPR years_type operator/(const int_type rhs)const
|
||||
{
|
||||
return years_type(_y / rhs);
|
||||
}
|
||||
years_type& operator/=(const int_type rhs)
|
||||
BOOST_CXX14_CONSTEXPR years_type& operator/=(const int_type rhs)
|
||||
{
|
||||
_y = _y / rhs;
|
||||
return *this;
|
||||
}
|
||||
months_type operator+(const months_type& m) const
|
||||
BOOST_CXX14_CONSTEXPR months_type operator+(const months_type& m) const
|
||||
{
|
||||
return(months_type(_y * 12 + m.number_of_months()));
|
||||
}
|
||||
months_type operator-(const months_type& m) const
|
||||
BOOST_CXX14_CONSTEXPR months_type operator-(const months_type& m) const
|
||||
{
|
||||
return(months_type(_y * 12 - m.number_of_months()));
|
||||
}
|
||||
|
||||
//
|
||||
friend date_type operator+(const date_type& d, const years_type& y)
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator+(const date_type& d, const years_type& y)
|
||||
{
|
||||
return d + y.get_offset(d);
|
||||
}
|
||||
friend date_type operator+=(date_type& d, const years_type& y)
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator+=(date_type& d, const years_type& y)
|
||||
{
|
||||
return d += y.get_offset(d);
|
||||
}
|
||||
friend date_type operator-(const date_type& d, const years_type& y)
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator-(const date_type& d, const years_type& y)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return d + y.get_neg_offset(d);
|
||||
}
|
||||
friend date_type operator-=(date_type& d, const years_type& y)
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator-=(date_type& d, const years_type& y)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return d += y.get_neg_offset(d);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef GREG_DATE_HPP___
|
||||
#define GREG_DATE_HPP___
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -48,12 +48,12 @@ namespace gregorian {
|
||||
typedef date_duration duration_type;
|
||||
#if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
|
||||
//! Default constructor constructs with not_a_date_time
|
||||
date():
|
||||
BOOST_CXX14_CONSTEXPR date():
|
||||
date_time::date<date, gregorian_calendar, date_duration>(date_rep_type::from_special(not_a_date_time))
|
||||
{}
|
||||
#endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR
|
||||
//! Main constructor with year, month, day
|
||||
date(year_type y, month_type m, day_type d)
|
||||
BOOST_CXX14_CONSTEXPR date(year_type y, month_type m, day_type d)
|
||||
: date_time::date<date, gregorian_calendar, date_duration>(y, m, d)
|
||||
{
|
||||
if (gregorian_calendar::end_of_month_day(y, m) < d) {
|
||||
@@ -61,19 +61,19 @@ namespace gregorian {
|
||||
}
|
||||
}
|
||||
//! Constructor from a ymd_type structure
|
||||
explicit date(const ymd_type& ymd)
|
||||
BOOST_CXX14_CONSTEXPR explicit date(const ymd_type& ymd)
|
||||
: date_time::date<date, gregorian_calendar, date_duration>(ymd)
|
||||
{}
|
||||
//! Needed copy constructor
|
||||
explicit date(const date_int_type& rhs):
|
||||
BOOST_CXX14_CONSTEXPR explicit date(const date_int_type& rhs):
|
||||
date_time::date<date,gregorian_calendar, date_duration>(rhs)
|
||||
{}
|
||||
//! Needed copy constructor
|
||||
explicit date(date_rep_type rhs):
|
||||
BOOST_CXX14_CONSTEXPR explicit date(date_rep_type rhs):
|
||||
date_time::date<date,gregorian_calendar, date_duration>(rhs)
|
||||
{}
|
||||
//! Constructor for infinities, not a date, max and min date
|
||||
explicit date(special_values sv):
|
||||
BOOST_CXX14_CONSTEXPR explicit date(special_values sv):
|
||||
date_time::date<date, gregorian_calendar, date_duration>(date_rep_type::from_special(sv))
|
||||
{
|
||||
if (sv == min_date_time)
|
||||
@@ -87,37 +87,37 @@ namespace gregorian {
|
||||
|
||||
}
|
||||
//!Return the Julian Day number for the date.
|
||||
date_int_type julian_day() const
|
||||
BOOST_CXX14_CONSTEXPR date_int_type julian_day() const
|
||||
{
|
||||
ymd_type ymd = year_month_day();
|
||||
return gregorian_calendar::julian_day_number(ymd);
|
||||
}
|
||||
//!Return the day of year 1..365 or 1..366 (for leap year)
|
||||
day_of_year_type day_of_year() const
|
||||
BOOST_CXX14_CONSTEXPR day_of_year_type day_of_year() const
|
||||
{
|
||||
date start_of_year(year(), 1, 1);
|
||||
unsigned short doy = static_cast<unsigned short>((*this-start_of_year).days() + 1);
|
||||
return day_of_year_type(doy);
|
||||
}
|
||||
//!Return the Modified Julian Day number for the date.
|
||||
date_int_type modjulian_day() const
|
||||
BOOST_CXX14_CONSTEXPR date_int_type modjulian_day() const
|
||||
{
|
||||
ymd_type ymd = year_month_day();
|
||||
return gregorian_calendar::modjulian_day_number(ymd);
|
||||
}
|
||||
//!Return the iso 8601 week number 1..53
|
||||
int week_number() const
|
||||
BOOST_CXX14_CONSTEXPR int week_number() const
|
||||
{
|
||||
ymd_type ymd = year_month_day();
|
||||
return gregorian_calendar::week_number(ymd);
|
||||
}
|
||||
//! Return the day number from the calendar
|
||||
date_int_type day_number() const
|
||||
BOOST_CXX14_CONSTEXPR date_int_type day_number() const
|
||||
{
|
||||
return days_;
|
||||
}
|
||||
//! Return the last day of the current month
|
||||
date end_of_month() const
|
||||
BOOST_CXX14_CONSTEXPR date end_of_month() const
|
||||
{
|
||||
ymd_type ymd = year_month_day();
|
||||
unsigned short eom_day = gregorian_calendar::end_of_month_day(ymd.year, ymd.month);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef GREG_DAY_HPP___
|
||||
#define GREG_DAY_HPP___
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
/* Copyright (c) 2002,2003,2020 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -42,9 +42,9 @@ namespace gregorian {
|
||||
*/
|
||||
class BOOST_SYMBOL_VISIBLE greg_day : public greg_day_rep {
|
||||
public:
|
||||
greg_day(value_type day_of_month) : greg_day_rep(day_of_month) {}
|
||||
value_type as_number() const {return value_;}
|
||||
operator value_type() const {return value_;}
|
||||
BOOST_CXX14_CONSTEXPR greg_day(value_type day_of_month) : greg_day_rep(day_of_month) {}
|
||||
BOOST_CXX14_CONSTEXPR value_type as_number() const {return value_;}
|
||||
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef GREG_DURATION_HPP___
|
||||
#define GREG_DURATION_HPP___
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -32,16 +32,20 @@ namespace gregorian {
|
||||
typedef base_type::duration_rep duration_rep;
|
||||
|
||||
//! Construct from a day count
|
||||
explicit date_duration(duration_rep day_count = 0) : base_type(day_count) {}
|
||||
BOOST_CXX14_CONSTEXPR explicit
|
||||
date_duration(duration_rep day_count = 0) : base_type(day_count) {}
|
||||
|
||||
//! construct from special_values
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
date_duration(date_time::special_values sv) : base_type(sv) {}
|
||||
|
||||
//! Copy constructor
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
date_duration(const date_duration& other) : base_type(static_cast< base_type const& >(other))
|
||||
{}
|
||||
|
||||
//! Construct from another date_duration
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
date_duration(const base_type& other) : base_type(other)
|
||||
{}
|
||||
|
||||
@@ -49,75 +53,77 @@ namespace gregorian {
|
||||
// NOTE: Because of date_time::date_duration< T > design choice we don't use Boost.Operators here,
|
||||
// because we need the class to be a direct base. Either lose EBO, or define operators by hand.
|
||||
// The latter is more effecient.
|
||||
bool operator== (const date_duration& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator== (const date_duration& rhs) const
|
||||
{
|
||||
return base_type::operator== (rhs);
|
||||
}
|
||||
bool operator!= (const date_duration& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator!= (const date_duration& rhs) const
|
||||
{
|
||||
return !operator== (rhs);
|
||||
}
|
||||
bool operator< (const date_duration& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator< (const date_duration& rhs) const
|
||||
{
|
||||
return base_type::operator< (rhs);
|
||||
}
|
||||
bool operator> (const date_duration& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator> (const date_duration& rhs) const
|
||||
{
|
||||
return !(base_type::operator< (rhs) || base_type::operator== (rhs));
|
||||
}
|
||||
bool operator<= (const date_duration& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator<= (const date_duration& rhs) const
|
||||
{
|
||||
return (base_type::operator< (rhs) || base_type::operator== (rhs));
|
||||
}
|
||||
bool operator>= (const date_duration& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator>= (const date_duration& rhs) const
|
||||
{
|
||||
return !base_type::operator< (rhs);
|
||||
}
|
||||
|
||||
//! Subtract another duration -- result is signed
|
||||
date_duration& operator-= (const date_duration& rhs)
|
||||
BOOST_CXX14_CONSTEXPR date_duration& operator-= (const date_duration& rhs)
|
||||
{
|
||||
base_type::operator-= (rhs);
|
||||
return *this;
|
||||
}
|
||||
friend date_duration operator- (date_duration rhs, date_duration const& lhs)
|
||||
BOOST_CXX14_CONSTEXPR friend
|
||||
date_duration operator- (date_duration rhs, date_duration const& lhs)
|
||||
{
|
||||
rhs -= lhs;
|
||||
return rhs;
|
||||
}
|
||||
|
||||
//! Add a duration -- result is signed
|
||||
date_duration& operator+= (const date_duration& rhs)
|
||||
BOOST_CXX14_CONSTEXPR date_duration& operator+= (const date_duration& rhs)
|
||||
{
|
||||
base_type::operator+= (rhs);
|
||||
return *this;
|
||||
}
|
||||
friend date_duration operator+ (date_duration rhs, date_duration const& lhs)
|
||||
BOOST_CXX14_CONSTEXPR friend
|
||||
date_duration operator+ (date_duration rhs, date_duration const& lhs)
|
||||
{
|
||||
rhs += lhs;
|
||||
return rhs;
|
||||
}
|
||||
|
||||
//! unary- Allows for dd = -date_duration(2); -> dd == -2
|
||||
date_duration operator- ()const
|
||||
BOOST_CXX14_CONSTEXPR date_duration operator- ()const
|
||||
{
|
||||
return date_duration(get_rep() * (-1));
|
||||
}
|
||||
|
||||
//! Division operations on a duration with an integer.
|
||||
date_duration& operator/= (int divisor)
|
||||
BOOST_CXX14_CONSTEXPR date_duration& operator/= (int divisor)
|
||||
{
|
||||
base_type::operator/= (divisor);
|
||||
return *this;
|
||||
}
|
||||
friend date_duration operator/ (date_duration rhs, int lhs)
|
||||
BOOST_CXX14_CONSTEXPR friend date_duration operator/ (date_duration rhs, int lhs)
|
||||
{
|
||||
rhs /= lhs;
|
||||
return rhs;
|
||||
}
|
||||
|
||||
//! Returns the smallest duration -- used by to calculate 'end'
|
||||
static date_duration unit()
|
||||
static BOOST_CXX14_CONSTEXPR date_duration unit()
|
||||
{
|
||||
return date_duration(base_type::unit().get_rep());
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ namespace gregorian {
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE weeks_duration : public date_duration {
|
||||
public:
|
||||
weeks_duration(duration_rep w)
|
||||
BOOST_CXX14_CONSTEXPR weeks_duration(duration_rep w)
|
||||
: date_duration(w * 7) {}
|
||||
weeks_duration(date_time::special_values sv)
|
||||
BOOST_CXX14_CONSTEXPR weeks_duration(date_time::special_values sv)
|
||||
: date_duration(sv) {}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef GREG_MONTH_HPP___
|
||||
#define GREG_MONTH_HPP___
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -58,15 +58,15 @@ namespace gregorian {
|
||||
typedef std::map<std::string, unsigned short> month_map_type;
|
||||
typedef boost::shared_ptr<month_map_type> month_map_ptr_type;
|
||||
//! Construct a month from the months_of_year enumeration
|
||||
greg_month(month_enum theMonth) :
|
||||
BOOST_CXX14_CONSTEXPR greg_month(month_enum theMonth) :
|
||||
greg_month_rep(static_cast<greg_month_rep::value_type>(theMonth)) {}
|
||||
//! Construct from a short value
|
||||
greg_month(value_type theMonth) : greg_month_rep(theMonth) {}
|
||||
BOOST_CXX14_CONSTEXPR greg_month(value_type theMonth) : greg_month_rep(theMonth) {}
|
||||
//! Convert the value back to a short
|
||||
operator value_type() const {return value_;}
|
||||
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
|
||||
//! Returns month as number from 1 to 12
|
||||
value_type as_number() const {return value_;}
|
||||
month_enum as_enum() const {return static_cast<month_enum>(value_);}
|
||||
BOOST_CXX14_CONSTEXPR value_type as_number() const {return value_;}
|
||||
BOOST_CXX14_CONSTEXPR month_enum as_enum() const {return static_cast<month_enum>(value_);}
|
||||
const char* as_short_string() const;
|
||||
const char* as_long_string() const;
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef GREG_WEEKDAY_HPP___
|
||||
#define GREG_WEEKDAY_HPP___
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
/* Copyright (c) 2002,2003,2020 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -41,18 +41,19 @@ namespace gregorian {
|
||||
class BOOST_DATE_TIME_DECL greg_weekday : public greg_weekday_rep {
|
||||
public:
|
||||
typedef boost::date_time::weekdays weekday_enum;
|
||||
greg_weekday(value_type day_of_week_num) :
|
||||
BOOST_CXX14_CONSTEXPR greg_weekday(value_type day_of_week_num) :
|
||||
greg_weekday_rep(day_of_week_num)
|
||||
{}
|
||||
|
||||
value_type as_number() const {return value_;}
|
||||
BOOST_CXX14_CONSTEXPR value_type as_number() const {return value_;}
|
||||
BOOST_CXX14_CONSTEXPR weekday_enum as_enum() const {return static_cast<weekday_enum>(value_);}
|
||||
|
||||
const char* as_short_string() const;
|
||||
const char* as_long_string() const;
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
const wchar_t* as_short_wstring() const;
|
||||
const wchar_t* as_long_wstring() const;
|
||||
#endif // BOOST_NO_STD_WSTRING
|
||||
weekday_enum as_enum() const {return static_cast<weekday_enum>(value_);}
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef GREG_YEAR_HPP___
|
||||
#define GREG_YEAR_HPP___
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -39,8 +39,8 @@ namespace gregorian {
|
||||
*/
|
||||
class BOOST_SYMBOL_VISIBLE greg_year : public greg_year_rep {
|
||||
public:
|
||||
greg_year(value_type year) : greg_year_rep(year) {}
|
||||
operator value_type() const {return value_;}
|
||||
BOOST_CXX14_CONSTEXPR greg_year(value_type year) : greg_year_rep(year) {}
|
||||
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -40,19 +40,18 @@ namespace date_time {
|
||||
typedef date_int_type_ date_int_type;
|
||||
|
||||
|
||||
static unsigned short day_of_week(const ymd_type& ymd);
|
||||
static int week_number(const ymd_type&ymd);
|
||||
//static unsigned short day_of_year(date_int_type);
|
||||
static date_int_type day_number(const ymd_type& ymd);
|
||||
static date_int_type julian_day_number(const ymd_type& ymd);
|
||||
static date_int_type modjulian_day_number(const ymd_type& ymd);
|
||||
static ymd_type from_day_number(date_int_type);
|
||||
static ymd_type from_julian_day_number(date_int_type);
|
||||
static ymd_type from_modjulian_day_number(date_int_type);
|
||||
static bool is_leap_year(year_type);
|
||||
static unsigned short end_of_month_day(year_type y, month_type m);
|
||||
static ymd_type epoch();
|
||||
static unsigned short days_in_week();
|
||||
static BOOST_CXX14_CONSTEXPR unsigned short day_of_week(const ymd_type& ymd);
|
||||
static BOOST_CXX14_CONSTEXPR int week_number(const ymd_type&ymd);
|
||||
static BOOST_CXX14_CONSTEXPR date_int_type day_number(const ymd_type& ymd);
|
||||
static BOOST_CXX14_CONSTEXPR date_int_type julian_day_number(const ymd_type& ymd);
|
||||
static BOOST_CXX14_CONSTEXPR date_int_type modjulian_day_number(const ymd_type& ymd);
|
||||
static BOOST_CXX14_CONSTEXPR ymd_type from_day_number(date_int_type);
|
||||
static BOOST_CXX14_CONSTEXPR ymd_type from_julian_day_number(date_int_type);
|
||||
static BOOST_CXX14_CONSTEXPR ymd_type from_modjulian_day_number(date_int_type);
|
||||
static BOOST_CXX14_CONSTEXPR bool is_leap_year(year_type);
|
||||
static BOOST_CXX14_CONSTEXPR unsigned short end_of_month_day(year_type y, month_type m);
|
||||
static BOOST_CXX14_CONSTEXPR ymd_type epoch();
|
||||
static BOOST_CXX14_CONSTEXPR unsigned short days_in_week();
|
||||
|
||||
};
|
||||
|
||||
@@ -60,9 +59,8 @@ namespace date_time {
|
||||
|
||||
} } //namespace
|
||||
|
||||
#ifndef NO_BOOST_DATE_TIME_INLINE
|
||||
#include "boost/date_time/gregorian_calendar.ipp"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,10 +6,6 @@
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#ifndef NO_BOOST_DATE_TIME_INLINE
|
||||
#undef BOOST_DATE_TIME_INLINE
|
||||
#define BOOST_DATE_TIME_INLINE inline
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
@@ -17,7 +13,8 @@ namespace date_time {
|
||||
/*! Converts a year-month-day into a day of the week number
|
||||
*/
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
unsigned short
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::day_of_week(const ymd_type& ymd) {
|
||||
unsigned short a = static_cast<unsigned short>((14-ymd.month)/12);
|
||||
@@ -35,7 +32,8 @@ namespace date_time {
|
||||
Reference for this algorithm is the Calendar FAQ by Claus Tondering, April 2000.
|
||||
*/
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
int
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::week_number(const ymd_type& ymd) {
|
||||
unsigned long julianbegin = julian_day_number(ymd_type(ymd.year,1,1));
|
||||
@@ -71,7 +69,8 @@ namespace date_time {
|
||||
/*! The day number is an absolute number of days since the start of count
|
||||
*/
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
date_int_type_
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::day_number(const ymd_type& ymd)
|
||||
{
|
||||
@@ -86,7 +85,8 @@ namespace date_time {
|
||||
/*! Since this implementation uses julian day internally, this is the same as the day_number.
|
||||
*/
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
date_int_type_
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::julian_day_number(const ymd_type& ymd)
|
||||
{
|
||||
@@ -98,7 +98,8 @@ namespace date_time {
|
||||
* MJD 0 thus started on 17 Nov 1858(Gregorian) at 00:00:00 UTC
|
||||
*/
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
date_int_type_
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::modjulian_day_number(const ymd_type& ymd)
|
||||
{
|
||||
@@ -107,7 +108,8 @@ namespace date_time {
|
||||
|
||||
//! Change a day number into a year-month-day
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
ymd_type_
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::from_day_number(date_int_type dayNumber)
|
||||
{
|
||||
@@ -127,7 +129,8 @@ namespace date_time {
|
||||
|
||||
//! Change a day number into a year-month-day
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
ymd_type_
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::from_julian_day_number(date_int_type dayNumber)
|
||||
{
|
||||
@@ -147,7 +150,8 @@ namespace date_time {
|
||||
|
||||
//! Change a modified julian day number into a year-month-day
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
ymd_type_
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::from_modjulian_day_number(date_int_type dayNumber) {
|
||||
date_int_type jd = dayNumber + 2400001; //is 2400000.5 prerounded
|
||||
@@ -159,7 +163,8 @@ namespace date_time {
|
||||
*@return true if year is a leap year, false otherwise
|
||||
*/
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
bool
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::is_leap_year(year_type year)
|
||||
{
|
||||
@@ -172,7 +177,8 @@ namespace date_time {
|
||||
* No error checking is performed.
|
||||
*/
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
unsigned short
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::end_of_month_day(year_type year,
|
||||
month_type month)
|
||||
@@ -197,7 +203,8 @@ namespace date_time {
|
||||
|
||||
//! Provide the ymd_type specification for the calandar start
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
ymd_type_
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::epoch()
|
||||
{
|
||||
@@ -206,7 +213,8 @@ namespace date_time {
|
||||
|
||||
//! Defines length of a week for week calculations
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
BOOST_DATE_TIME_INLINE
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
inline
|
||||
unsigned short
|
||||
gregorian_calendar_base<ymd_type_,date_int_type_>::days_in_week()
|
||||
{
|
||||
|
||||
@@ -46,34 +46,34 @@ template<typename int_type_>
|
||||
class int_adapter {
|
||||
public:
|
||||
typedef int_type_ int_type;
|
||||
int_adapter(int_type v) :
|
||||
BOOST_CXX14_CONSTEXPR int_adapter(int_type v) :
|
||||
value_(v)
|
||||
{}
|
||||
static bool has_infinity()
|
||||
static BOOST_CONSTEXPR_OR_CONST bool has_infinity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
static const int_adapter pos_infinity()
|
||||
static BOOST_CONSTEXPR_OR_CONST int_adapter pos_infinity()
|
||||
{
|
||||
return (::std::numeric_limits<int_type>::max)();
|
||||
}
|
||||
static const int_adapter neg_infinity()
|
||||
static BOOST_CONSTEXPR_OR_CONST int_adapter neg_infinity()
|
||||
{
|
||||
return (::std::numeric_limits<int_type>::min)();
|
||||
}
|
||||
static const int_adapter not_a_number()
|
||||
static BOOST_CONSTEXPR_OR_CONST int_adapter not_a_number()
|
||||
{
|
||||
return (::std::numeric_limits<int_type>::max)()-1;
|
||||
}
|
||||
static int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION ()
|
||||
static BOOST_CONSTEXPR_OR_CONST int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION ()
|
||||
{
|
||||
return (::std::numeric_limits<int_type>::max)()-2;
|
||||
}
|
||||
static int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION ()
|
||||
static BOOST_CONSTEXPR_OR_CONST int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION ()
|
||||
{
|
||||
return (::std::numeric_limits<int_type>::min)()+1;
|
||||
}
|
||||
static int_adapter from_special(special_values sv)
|
||||
static BOOST_CXX14_CONSTEXPR int_adapter from_special(special_values sv)
|
||||
{
|
||||
switch (sv) {
|
||||
case not_a_date_time: return not_a_number();
|
||||
@@ -84,25 +84,25 @@ public:
|
||||
default: return not_a_number();
|
||||
}
|
||||
}
|
||||
static bool is_inf(int_type v)
|
||||
static BOOST_CONSTEXPR_OR_CONST bool is_inf(int_type v)
|
||||
{
|
||||
return (v == neg_infinity().as_number() ||
|
||||
v == pos_infinity().as_number());
|
||||
}
|
||||
static bool is_neg_inf(int_type v)
|
||||
static BOOST_CONSTEXPR_OR_CONST bool is_neg_inf(int_type v)
|
||||
{
|
||||
return (v == neg_infinity().as_number());
|
||||
}
|
||||
static bool is_pos_inf(int_type v)
|
||||
static BOOST_CONSTEXPR_OR_CONST bool is_pos_inf(int_type v)
|
||||
{
|
||||
return (v == pos_infinity().as_number());
|
||||
}
|
||||
static bool is_not_a_number(int_type v)
|
||||
static BOOST_CONSTEXPR_OR_CONST bool is_not_a_number(int_type v)
|
||||
{
|
||||
return (v == not_a_number().as_number());
|
||||
}
|
||||
//! Returns either special value type or is_not_special
|
||||
static special_values to_special(int_type v)
|
||||
static BOOST_CXX14_CONSTEXPR special_values to_special(int_type v)
|
||||
{
|
||||
if (is_not_a_number(v)) return not_a_date_time;
|
||||
if (is_neg_inf(v)) return neg_infin;
|
||||
@@ -111,36 +111,36 @@ public:
|
||||
}
|
||||
|
||||
//-3 leaves room for representations of infinity and not a date
|
||||
static int_type maxcount()
|
||||
static BOOST_CONSTEXPR_OR_CONST int_type maxcount()
|
||||
{
|
||||
return (::std::numeric_limits<int_type>::max)()-3;
|
||||
}
|
||||
bool is_infinity() const
|
||||
BOOST_CONSTEXPR bool is_infinity() const
|
||||
{
|
||||
return (value_ == neg_infinity().as_number() ||
|
||||
value_ == pos_infinity().as_number());
|
||||
}
|
||||
bool is_pos_infinity()const
|
||||
BOOST_CONSTEXPR bool is_pos_infinity()const
|
||||
{
|
||||
return(value_ == pos_infinity().as_number());
|
||||
}
|
||||
bool is_neg_infinity()const
|
||||
BOOST_CONSTEXPR bool is_neg_infinity()const
|
||||
{
|
||||
return(value_ == neg_infinity().as_number());
|
||||
}
|
||||
bool is_nan() const
|
||||
BOOST_CONSTEXPR bool is_nan() const
|
||||
{
|
||||
return (value_ == not_a_number().as_number());
|
||||
}
|
||||
bool is_special() const
|
||||
BOOST_CONSTEXPR bool is_special() const
|
||||
{
|
||||
return(is_infinity() || is_nan());
|
||||
}
|
||||
bool operator==(const int_adapter& rhs) const
|
||||
BOOST_CONSTEXPR bool operator==(const int_adapter& rhs) const
|
||||
{
|
||||
return (compare(rhs) == 0);
|
||||
}
|
||||
bool operator==(const int& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator==(const int& rhs) const
|
||||
{
|
||||
if(!std::numeric_limits<int_type>::is_signed)
|
||||
{
|
||||
@@ -151,11 +151,11 @@ public:
|
||||
}
|
||||
return (compare(rhs) == 0);
|
||||
}
|
||||
bool operator!=(const int_adapter& rhs) const
|
||||
BOOST_CONSTEXPR bool operator!=(const int_adapter& rhs) const
|
||||
{
|
||||
return (compare(rhs) != 0);
|
||||
}
|
||||
bool operator!=(const int& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator!=(const int& rhs) const
|
||||
{
|
||||
if(!std::numeric_limits<int_type>::is_signed)
|
||||
{
|
||||
@@ -166,11 +166,11 @@ public:
|
||||
}
|
||||
return (compare(rhs) != 0);
|
||||
}
|
||||
bool operator<(const int_adapter& rhs) const
|
||||
BOOST_CONSTEXPR bool operator<(const int_adapter& rhs) const
|
||||
{
|
||||
return (compare(rhs) == -1);
|
||||
}
|
||||
bool operator<(const int& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR bool operator<(const int& rhs) const
|
||||
{
|
||||
// quiets compiler warnings
|
||||
if(!std::numeric_limits<int_type>::is_signed)
|
||||
@@ -182,16 +182,16 @@ public:
|
||||
}
|
||||
return (compare(rhs) == -1);
|
||||
}
|
||||
bool operator>(const int_adapter& rhs) const
|
||||
BOOST_CONSTEXPR bool operator>(const int_adapter& rhs) const
|
||||
{
|
||||
return (compare(rhs) == 1);
|
||||
}
|
||||
int_type as_number() const
|
||||
BOOST_CONSTEXPR int_type as_number() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
//! Returns either special value type or is_not_special
|
||||
special_values as_special() const
|
||||
BOOST_CONSTEXPR special_values as_special() const
|
||||
{
|
||||
return int_adapter::to_special(value_);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public:
|
||||
/*! Operator allows for adding dissimilar int_adapter types.
|
||||
* The return type will match that of the the calling object's type */
|
||||
template<class rhs_type>
|
||||
inline
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter operator+(const int_adapter<rhs_type>& rhs) const
|
||||
{
|
||||
if(is_special() || rhs.is_special())
|
||||
@@ -234,6 +234,7 @@ public:
|
||||
return int_adapter<int_type>(value_ + static_cast<int_type>(rhs.as_number()));
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter operator+(const int_type rhs) const
|
||||
{
|
||||
if(is_special())
|
||||
@@ -253,7 +254,7 @@ public:
|
||||
/*! Operator allows for subtracting dissimilar int_adapter types.
|
||||
* The return type will match that of the the calling object's type */
|
||||
template<class rhs_type>
|
||||
inline
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter operator-(const int_adapter<rhs_type>& rhs)const
|
||||
{
|
||||
if(is_special() || rhs.is_special())
|
||||
@@ -282,6 +283,8 @@ public:
|
||||
}
|
||||
return int_adapter<int_type>(value_ - static_cast<int_type>(rhs.as_number()));
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter operator-(const int_type rhs) const
|
||||
{
|
||||
if(is_special())
|
||||
@@ -299,6 +302,7 @@ public:
|
||||
}
|
||||
|
||||
// should templatize this to be consistant with op +-
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter operator*(const int_adapter& rhs)const
|
||||
{
|
||||
if(this->is_special() || rhs.is_special())
|
||||
@@ -307,8 +311,10 @@ public:
|
||||
}
|
||||
return int_adapter<int_type>(value_ * rhs.value_);
|
||||
}
|
||||
|
||||
/*! Provided for cases when automatic conversion from
|
||||
* 'int' to 'int_adapter' causes incorrect results. */
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter operator*(const int rhs) const
|
||||
{
|
||||
if(is_special())
|
||||
@@ -319,6 +325,7 @@ public:
|
||||
}
|
||||
|
||||
// should templatize this to be consistant with op +-
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter operator/(const int_adapter& rhs)const
|
||||
{
|
||||
if(this->is_special() || rhs.is_special())
|
||||
@@ -332,23 +339,27 @@ public:
|
||||
return mult_div_specials(rhs);
|
||||
}
|
||||
else { // let divide by zero blow itself up
|
||||
return int_adapter<int_type>(value_ / rhs.value_);
|
||||
return int_adapter<int_type>(value_ / rhs.value_); //NOLINT
|
||||
}
|
||||
}
|
||||
return int_adapter<int_type>(value_ / rhs.value_);
|
||||
}
|
||||
|
||||
/*! Provided for cases when automatic conversion from
|
||||
* 'int' to 'int_adapter' causes incorrect results. */
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter operator/(const int rhs) const
|
||||
{
|
||||
if(is_special() && rhs != 0)
|
||||
{
|
||||
return mult_div_specials(rhs);
|
||||
}
|
||||
return int_adapter<int_type>(value_ / rhs);
|
||||
// let divide by zero blow itself up like int
|
||||
return int_adapter<int_type>(value_ / rhs); //NOLINT
|
||||
}
|
||||
|
||||
// should templatize this to be consistant with op +-
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter operator%(const int_adapter& rhs)const
|
||||
{
|
||||
if(this->is_special() || rhs.is_special())
|
||||
@@ -362,26 +373,31 @@ public:
|
||||
return mult_div_specials(rhs);
|
||||
}
|
||||
else { // let divide by zero blow itself up
|
||||
return int_adapter<int_type>(value_ % rhs.value_);
|
||||
return int_adapter<int_type>(value_ % rhs.value_); //NOLINT
|
||||
}
|
||||
}
|
||||
return int_adapter<int_type>(value_ % rhs.value_);
|
||||
}
|
||||
|
||||
/*! Provided for cases when automatic conversion from
|
||||
* 'int' to 'int_adapter' causes incorrect results. */
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter operator%(const int rhs) const
|
||||
{
|
||||
if(is_special() && rhs != 0)
|
||||
{
|
||||
return mult_div_specials(rhs);
|
||||
}
|
||||
return int_adapter<int_type>(value_ % rhs);
|
||||
// let divide by zero blow itself up
|
||||
return int_adapter<int_type>(value_ % rhs); //NOLINT
|
||||
}
|
||||
|
||||
private:
|
||||
int_type value_;
|
||||
|
||||
//! returns -1, 0, 1, or 2 if 'this' is <, ==, >, or 'nan comparison' rhs
|
||||
int compare(const int_adapter& rhs)const
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int compare( const int_adapter& rhs ) const
|
||||
{
|
||||
if(this->is_special() || rhs.is_special())
|
||||
{
|
||||
@@ -408,12 +424,14 @@ private:
|
||||
// implied-> if(value_ == rhs.value_)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* When multiplying and dividing with at least 1 special value
|
||||
* very simmilar rules apply. In those cases where the rules
|
||||
* are different, they are handled in the respective operator
|
||||
* function. */
|
||||
//! Assumes at least 'this' or 'rhs' is a special value
|
||||
int_adapter mult_div_specials(const int_adapter& rhs)const
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter mult_div_specials(const int_adapter& rhs) const
|
||||
{
|
||||
if(this->is_nan() || rhs.is_nan()) {
|
||||
return int_adapter<int_type>(not_a_number());
|
||||
@@ -428,12 +446,14 @@ private:
|
||||
//implied -> if(this->value_ == 0 || rhs.value_ == 0)
|
||||
return int_adapter<int_type>(not_a_number());
|
||||
}
|
||||
|
||||
/* Overloaded function necessary because of special
|
||||
* situation where int_adapter is instantiated with
|
||||
* 'unsigned' and func is called with negative int.
|
||||
* It would produce incorrect results since 'unsigned'
|
||||
* wraps around when initialized with a negative value */
|
||||
//! Assumes 'this' is a special value
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
int_adapter mult_div_specials(const int& rhs) const
|
||||
{
|
||||
if(this->is_nan()) {
|
||||
@@ -449,7 +469,7 @@ private:
|
||||
//implied -> if(this->value_ == 0 || rhs.value_ == 0)
|
||||
return int_adapter<int_type>(not_a_number());
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#ifndef BOOST_DATE_TIME_NO_LOCALE
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef DATE_TIME_LOCALE_CONFIG_HPP___
|
||||
#define DATE_TIME_LOCALE_CONFIG_HPP___
|
||||
|
||||
/* Copyright (c) 2002-2006 CrystalClear Software, Inc.
|
||||
/* Copyright (c) 2002-2020 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,7 +17,7 @@
|
||||
// defines BOOST_NO_STD_LOCALE (gcc 2.95.x)
|
||||
|
||||
#include "boost/config.hpp" //sets BOOST_NO_STD_LOCALE
|
||||
#include "boost/detail/workaround.hpp"
|
||||
#include "boost/config/workaround.hpp"
|
||||
|
||||
//This file basically becomes a noop if locales are not properly supported
|
||||
#if (defined(BOOST_NO_STD_LOCALE) \
|
||||
|
||||
@@ -58,26 +58,26 @@ namespace date_time {
|
||||
typedef point_rep point_type;
|
||||
typedef duration_rep duration_type;
|
||||
|
||||
period(point_rep first_point, point_rep end_point);
|
||||
period(point_rep first_point, duration_rep len);
|
||||
point_rep begin() const;
|
||||
point_rep end() const;
|
||||
point_rep last() const;
|
||||
duration_rep length() const;
|
||||
bool is_null() const;
|
||||
bool operator==(const period& rhs) const;
|
||||
bool operator<(const period& rhs) const;
|
||||
void shift(const duration_rep& d);
|
||||
void expand(const duration_rep& d);
|
||||
bool contains(const point_rep& point) const;
|
||||
bool contains(const period& other) const;
|
||||
bool intersects(const period& other) const;
|
||||
bool is_adjacent(const period& other) const;
|
||||
bool is_before(const point_rep& point) const;
|
||||
bool is_after(const point_rep& point) const;
|
||||
period intersection(const period& other) const;
|
||||
period merge(const period& other) const;
|
||||
period span(const period& other) const;
|
||||
BOOST_CXX14_CONSTEXPR period(point_rep first_point, point_rep end_point);
|
||||
BOOST_CXX14_CONSTEXPR period(point_rep first_point, duration_rep len);
|
||||
BOOST_CXX14_CONSTEXPR point_rep begin() const;
|
||||
BOOST_CXX14_CONSTEXPR point_rep end() const;
|
||||
BOOST_CXX14_CONSTEXPR point_rep last() const;
|
||||
BOOST_CXX14_CONSTEXPR duration_rep length() const;
|
||||
BOOST_CXX14_CONSTEXPR bool is_null() const;
|
||||
BOOST_CXX14_CONSTEXPR bool operator==(const period& rhs) const;
|
||||
BOOST_CXX14_CONSTEXPR bool operator<(const period& rhs) const;
|
||||
BOOST_CXX14_CONSTEXPR void shift(const duration_rep& d);
|
||||
BOOST_CXX14_CONSTEXPR void expand(const duration_rep& d);
|
||||
BOOST_CXX14_CONSTEXPR bool contains(const point_rep& point) const;
|
||||
BOOST_CXX14_CONSTEXPR bool contains(const period& other) const;
|
||||
BOOST_CXX14_CONSTEXPR bool intersects(const period& other) const;
|
||||
BOOST_CXX14_CONSTEXPR bool is_adjacent(const period& other) const;
|
||||
BOOST_CXX14_CONSTEXPR bool is_before(const point_rep& point) const;
|
||||
BOOST_CXX14_CONSTEXPR bool is_after(const point_rep& point) const;
|
||||
BOOST_CXX14_CONSTEXPR period intersection(const period& other) const;
|
||||
BOOST_CXX14_CONSTEXPR period merge(const period& other) const;
|
||||
BOOST_CXX14_CONSTEXPR period span(const period& other) const;
|
||||
private:
|
||||
point_rep begin_;
|
||||
point_rep last_;
|
||||
@@ -87,7 +87,7 @@ namespace date_time {
|
||||
/*! If end <= begin then the period will be invalid
|
||||
*/
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
period<point_rep,duration_rep>::period(point_rep first_point,
|
||||
point_rep end_point) :
|
||||
begin_(first_point),
|
||||
@@ -98,7 +98,7 @@ namespace date_time {
|
||||
/*! If len is <= 0 then the period will be invalid
|
||||
*/
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
period<point_rep,duration_rep>::period(point_rep first_point, duration_rep len) :
|
||||
begin_(first_point),
|
||||
last_(first_point + len-duration_rep::unit())
|
||||
@@ -107,7 +107,7 @@ namespace date_time {
|
||||
|
||||
//! Return the first element in the period
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
point_rep period<point_rep,duration_rep>::begin() const
|
||||
{
|
||||
return begin_;
|
||||
@@ -115,7 +115,7 @@ namespace date_time {
|
||||
|
||||
//! Return one past the last element
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
point_rep period<point_rep,duration_rep>::end() const
|
||||
{
|
||||
return last_ + duration_rep::unit();
|
||||
@@ -123,7 +123,7 @@ namespace date_time {
|
||||
|
||||
//! Return the last item in the period
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
point_rep period<point_rep,duration_rep>::last() const
|
||||
{
|
||||
return last_;
|
||||
@@ -131,7 +131,7 @@ namespace date_time {
|
||||
|
||||
//! True if period is ill formed (length is zero or less)
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
bool period<point_rep,duration_rep>::is_null() const
|
||||
{
|
||||
return end() <= begin_;
|
||||
@@ -139,7 +139,7 @@ namespace date_time {
|
||||
|
||||
//! Return the length of the period
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
duration_rep period<point_rep,duration_rep>::length() const
|
||||
{
|
||||
if(last_ < begin_){ // invalid period
|
||||
@@ -152,7 +152,7 @@ namespace date_time {
|
||||
|
||||
//! Equality operator
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
bool period<point_rep,duration_rep>::operator==(const period& rhs) const
|
||||
{
|
||||
return ((begin_ == rhs.begin_) &&
|
||||
@@ -161,7 +161,7 @@ namespace date_time {
|
||||
|
||||
//! Strict as defined by rhs.last <= lhs.last
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
bool period<point_rep,duration_rep>::operator<(const period& rhs) const
|
||||
{
|
||||
return (last_ < rhs.begin_);
|
||||
@@ -170,7 +170,7 @@ namespace date_time {
|
||||
|
||||
//! Shift the start and end by the specified amount
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
void period<point_rep,duration_rep>::shift(const duration_rep& d)
|
||||
{
|
||||
begin_ = begin_ + d;
|
||||
@@ -197,7 +197,7 @@ namespace date_time {
|
||||
*@endcode
|
||||
*/
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
void period<point_rep,duration_rep>::expand(const duration_rep& d)
|
||||
{
|
||||
begin_ = begin_ - d;
|
||||
@@ -206,7 +206,7 @@ namespace date_time {
|
||||
|
||||
//! True if the point is inside the period, zero length periods contain no points
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
bool period<point_rep,duration_rep>::contains(const point_rep& point) const
|
||||
{
|
||||
return ((point >= begin_) &&
|
||||
@@ -216,7 +216,7 @@ namespace date_time {
|
||||
|
||||
//! True if this period fully contains (or equals) the other period
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
bool period<point_rep,duration_rep>::contains(const period<point_rep,duration_rep>& other) const
|
||||
{
|
||||
return ((begin_ <= other.begin_) && (last_ >= other.last_));
|
||||
@@ -233,9 +233,8 @@ namespace date_time {
|
||||
*@endcode
|
||||
*/
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
bool
|
||||
period<point_rep,duration_rep>::is_adjacent(const period<point_rep,duration_rep>& other) const
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
bool period<point_rep,duration_rep>::is_adjacent(const period<point_rep,duration_rep>& other) const
|
||||
{
|
||||
return (other.begin() == end() ||
|
||||
begin_ == other.end());
|
||||
@@ -252,9 +251,8 @@ namespace date_time {
|
||||
*@endcode
|
||||
*/
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
bool
|
||||
period<point_rep,duration_rep>::is_after(const point_rep& t) const
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
bool period<point_rep,duration_rep>::is_after(const point_rep& t) const
|
||||
{
|
||||
if (is_null())
|
||||
{
|
||||
@@ -274,9 +272,8 @@ namespace date_time {
|
||||
*@endcode
|
||||
*/
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
bool
|
||||
period<point_rep,duration_rep>::is_before(const point_rep& t) const
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
bool period<point_rep,duration_rep>::is_before(const point_rep& t) const
|
||||
{
|
||||
if (is_null())
|
||||
{
|
||||
@@ -299,8 +296,8 @@ namespace date_time {
|
||||
*@endcode
|
||||
*/
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
bool period<point_rep,duration_rep>::intersects(const period<point_rep,duration_rep>& other) const
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
bool period<point_rep,duration_rep>::intersects(const period<point_rep,duration_rep>& other) const
|
||||
{
|
||||
return ( contains(other.begin_) ||
|
||||
other.contains(begin_) ||
|
||||
@@ -309,7 +306,7 @@ namespace date_time {
|
||||
|
||||
//! Returns the period of intersection or invalid range no intersection
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
period<point_rep,duration_rep>
|
||||
period<point_rep,duration_rep>::intersection(const period<point_rep,duration_rep>& other) const
|
||||
{
|
||||
@@ -334,7 +331,7 @@ namespace date_time {
|
||||
/*!
|
||||
*/
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
period<point_rep,duration_rep>
|
||||
period<point_rep,duration_rep>::merge(const period<point_rep,duration_rep>& other) const
|
||||
{
|
||||
@@ -361,7 +358,7 @@ namespace date_time {
|
||||
*@endcode
|
||||
*/
|
||||
template<class point_rep, class duration_rep>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
period<point_rep,duration_rep>
|
||||
period<point_rep,duration_rep>::span(const period<point_rep,duration_rep>& other) const
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace posix_time {
|
||||
/*! Adds a months object and a ptime. Result will be same
|
||||
* day-of-month as ptime unless original day was the last day of month.
|
||||
* see date_time::months_duration for more details */
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
ptime
|
||||
operator+(const ptime& t, const boost::gregorian::months& m)
|
||||
{
|
||||
@@ -36,7 +36,7 @@ namespace posix_time {
|
||||
/*! Adds a months object to a ptime. Result will be same
|
||||
* day-of-month as ptime unless original day was the last day of month.
|
||||
* see date_time::months_duration for more details */
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
ptime
|
||||
operator+=(ptime& t, const boost::gregorian::months& m)
|
||||
{
|
||||
@@ -47,7 +47,7 @@ namespace posix_time {
|
||||
/*! Subtracts a months object and a ptime. Result will be same
|
||||
* day-of-month as ptime unless original day was the last day of month.
|
||||
* see date_time::months_duration for more details */
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
ptime
|
||||
operator-(const ptime& t, const boost::gregorian::months& m)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ namespace posix_time {
|
||||
/*! Subtracts a months object from a ptime. Result will be same
|
||||
* day-of-month as ptime unless original day was the last day of month.
|
||||
* see date_time::months_duration for more details */
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
ptime
|
||||
operator-=(ptime& t, const boost::gregorian::months& m)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ namespace posix_time {
|
||||
/*! Adds a years object and a ptime. Result will be same
|
||||
* month and day-of-month as ptime unless original day was the
|
||||
* last day of month. see date_time::years_duration for more details */
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
ptime
|
||||
operator+(const ptime& t, const boost::gregorian::years& y)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ namespace posix_time {
|
||||
/*! Adds a years object to a ptime. Result will be same
|
||||
* month and day-of-month as ptime unless original day was the
|
||||
* last day of month. see date_time::years_duration for more details */
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
ptime
|
||||
operator+=(ptime& t, const boost::gregorian::years& y)
|
||||
{
|
||||
@@ -90,7 +90,7 @@ namespace posix_time {
|
||||
/*! Subtracts a years object and a ptime. Result will be same
|
||||
* month and day-of-month as ptime unless original day was the
|
||||
* last day of month. see date_time::years_duration for more details */
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
ptime
|
||||
operator-(const ptime& t, const boost::gregorian::years& y)
|
||||
{
|
||||
@@ -101,7 +101,7 @@ namespace posix_time {
|
||||
/*! Subtracts a years object from a ptime. Result will be same
|
||||
* month and day-of-month as ptime unless original day was the
|
||||
* last day of month. see date_time::years_duration for more details */
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
ptime
|
||||
operator-=(ptime& t, const boost::gregorian::years& y)
|
||||
{
|
||||
|
||||
@@ -66,23 +66,23 @@ namespace posix_time {
|
||||
typedef time_res_traits::fractional_seconds_type fractional_seconds_type;
|
||||
typedef time_res_traits::tick_type tick_type;
|
||||
typedef time_res_traits::impl_type impl_type;
|
||||
time_duration(hour_type hour,
|
||||
min_type min,
|
||||
sec_type sec,
|
||||
fractional_seconds_type fs=0) :
|
||||
BOOST_CXX14_CONSTEXPR time_duration(hour_type hour,
|
||||
min_type min,
|
||||
sec_type sec,
|
||||
fractional_seconds_type fs=0) :
|
||||
date_time::time_duration<time_duration, time_res_traits>(hour,min,sec,fs)
|
||||
{}
|
||||
time_duration() :
|
||||
BOOST_CXX14_CONSTEXPR time_duration() :
|
||||
date_time::time_duration<time_duration, time_res_traits>(0,0,0)
|
||||
{}
|
||||
//! Construct from special_values
|
||||
time_duration(boost::date_time::special_values sv) :
|
||||
BOOST_CXX14_CONSTEXPR time_duration(boost::date_time::special_values sv) :
|
||||
date_time::time_duration<time_duration, time_res_traits>(sv)
|
||||
{}
|
||||
//Give duration access to ticks constructor -- hide from users
|
||||
friend class date_time::time_duration<time_duration, time_res_traits>;
|
||||
protected:
|
||||
explicit time_duration(impl_type tick_count) :
|
||||
BOOST_CXX14_CONSTEXPR explicit time_duration(impl_type tick_count) :
|
||||
date_time::time_duration<time_duration, time_res_traits>(tick_count)
|
||||
{}
|
||||
};
|
||||
@@ -94,7 +94,7 @@ namespace posix_time {
|
||||
{
|
||||
typedef gregorian::date date_type;
|
||||
typedef time_duration time_duration_type;
|
||||
simple_time_rep(date_type d, time_duration_type tod) :
|
||||
BOOST_CXX14_CONSTEXPR simple_time_rep(date_type d, time_duration_type tod) :
|
||||
day(d),
|
||||
time_of_day(tod)
|
||||
{
|
||||
@@ -116,19 +116,19 @@ namespace posix_time {
|
||||
}
|
||||
date_type day;
|
||||
time_duration_type time_of_day;
|
||||
bool is_special()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_special()const
|
||||
{
|
||||
return(is_pos_infinity() || is_neg_infinity() || is_not_a_date_time());
|
||||
}
|
||||
bool is_pos_infinity()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_pos_infinity()const
|
||||
{
|
||||
return(day.is_pos_infinity() || time_of_day.is_pos_infinity());
|
||||
}
|
||||
bool is_neg_infinity()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_neg_infinity()const
|
||||
{
|
||||
return(day.is_neg_infinity() || time_of_day.is_neg_infinity());
|
||||
}
|
||||
bool is_not_a_date_time()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_not_a_date_time()const
|
||||
{
|
||||
return(day.is_not_a_date() || time_of_day.is_not_a_date_time());
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POSIX_TIME_DURATION_HPP___
|
||||
#define POSIX_TIME_DURATION_HPP___
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -26,7 +26,7 @@ namespace posix_time {
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
explicit hours(T const& h,
|
||||
BOOST_CXX14_CONSTEXPR explicit hours(T const& h,
|
||||
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
|
||||
time_duration(numeric_cast<hour_type>(h), 0, 0)
|
||||
{}
|
||||
@@ -40,7 +40,7 @@ namespace posix_time {
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
explicit minutes(T const& m,
|
||||
BOOST_CXX14_CONSTEXPR explicit minutes(T const& m,
|
||||
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
|
||||
time_duration(0, numeric_cast<min_type>(m),0)
|
||||
{}
|
||||
@@ -54,7 +54,7 @@ namespace posix_time {
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
explicit seconds(T const& s,
|
||||
BOOST_CXX14_CONSTEXPR explicit seconds(T const& s,
|
||||
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
|
||||
time_duration(0,0, numeric_cast<sec_type>(s))
|
||||
{}
|
||||
|
||||
@@ -37,21 +37,31 @@ namespace posix_time {
|
||||
typedef time_system_type::time_duration_type time_duration_type;
|
||||
typedef ptime time_type;
|
||||
//! Construct with date and offset in day
|
||||
ptime(gregorian::date d,time_duration_type td) : date_time::base_time<time_type,time_system_type>(d,td)
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
ptime(gregorian::date d,time_duration_type td) :
|
||||
date_time::base_time<time_type,time_system_type>(d,td)
|
||||
{}
|
||||
//! Construct a time at start of the given day (midnight)
|
||||
explicit ptime(gregorian::date d) : date_time::base_time<time_type,time_system_type>(d,time_duration_type(0,0,0))
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
explicit ptime(gregorian::date d) :
|
||||
date_time::base_time<time_type,time_system_type>(d,time_duration_type(0,0,0))
|
||||
{}
|
||||
//! Copy from time_rep
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
ptime(const time_rep_type& rhs):
|
||||
date_time::base_time<time_type,time_system_type>(rhs)
|
||||
{}
|
||||
//! Construct from special value
|
||||
ptime(const special_values sv) : date_time::base_time<time_type,time_system_type>(sv)
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
ptime(const special_values sv) :
|
||||
date_time::base_time<time_type,time_system_type>(sv)
|
||||
{}
|
||||
#if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
|
||||
// Default constructor constructs to not_a_date_time
|
||||
ptime() : date_time::base_time<time_type,time_system_type>(gregorian::date(not_a_date_time), time_duration_type(not_a_date_time))
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
ptime() :
|
||||
date_time::base_time<time_type,time_system_type>(gregorian::date(not_a_date_time),
|
||||
time_duration_type(not_a_date_time))
|
||||
{}
|
||||
#endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef DATE_TIME_TIME_HPP___
|
||||
#define DATE_TIME_TIME_HPP___
|
||||
|
||||
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
|
||||
/* Copyright (c) 2002,2003,2005,2020 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -58,21 +58,26 @@ namespace date_time {
|
||||
typedef typename time_system::time_duration_type time_duration_type;
|
||||
//typedef typename time_system::hms_type hms_type;
|
||||
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
base_time(const date_type& day,
|
||||
const time_duration_type& td,
|
||||
dst_flags dst=not_dst) :
|
||||
time_(time_system::get_time_rep(day, td, dst))
|
||||
{}
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
base_time(special_values sv) :
|
||||
time_(time_system::get_time_rep(sv))
|
||||
{}
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
base_time(const time_rep_type& rhs) :
|
||||
time_(rhs)
|
||||
{}
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
date_type date() const
|
||||
{
|
||||
return time_system::get_date(time_);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_duration_type time_of_day() const
|
||||
{
|
||||
return time_system::get_time_of_day(time_);
|
||||
@@ -98,80 +103,96 @@ namespace date_time {
|
||||
}
|
||||
|
||||
//! check to see if date is not a value
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
bool is_not_a_date_time() const
|
||||
{
|
||||
return time_.is_not_a_date_time();
|
||||
}
|
||||
//! check to see if date is one of the infinity values
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
bool is_infinity() const
|
||||
{
|
||||
return (is_pos_infinity() || is_neg_infinity());
|
||||
}
|
||||
//! check to see if date is greater than all possible dates
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
bool is_pos_infinity() const
|
||||
{
|
||||
return time_.is_pos_infinity();
|
||||
}
|
||||
//! check to see if date is greater than all possible dates
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
bool is_neg_infinity() const
|
||||
{
|
||||
return time_.is_neg_infinity();
|
||||
}
|
||||
//! check to see if time is a special value
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
bool is_special() const
|
||||
{
|
||||
return(is_not_a_date_time() || is_infinity());
|
||||
}
|
||||
//!Equality operator -- others generated by boost::equality_comparable
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
bool operator==(const time_type& rhs) const
|
||||
{
|
||||
return time_system::is_equal(time_,rhs.time_);
|
||||
}
|
||||
//!Equality operator -- others generated by boost::less_than_comparable
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
bool operator<(const time_type& rhs) const
|
||||
{
|
||||
return time_system::is_less(time_,rhs.time_);
|
||||
}
|
||||
//! difference between two times
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_duration_type operator-(const time_type& rhs) const
|
||||
{
|
||||
return time_system::subtract_times(time_, rhs.time_);
|
||||
}
|
||||
//! add date durations
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_type operator+(const date_duration_type& dd) const
|
||||
{
|
||||
return time_system::add_days(time_, dd);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_type operator+=(const date_duration_type& dd)
|
||||
{
|
||||
time_ = (time_system::get_time_rep(date() + dd, time_of_day()));
|
||||
return time_type(time_);
|
||||
}
|
||||
//! subtract date durations
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_type operator-(const date_duration_type& dd) const
|
||||
{
|
||||
return time_system::subtract_days(time_, dd);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_type operator-=(const date_duration_type& dd)
|
||||
{
|
||||
time_ = (time_system::get_time_rep(date() - dd, time_of_day()));
|
||||
return time_type(time_);
|
||||
}
|
||||
//! add time durations
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_type operator+(const time_duration_type& td) const
|
||||
{
|
||||
return time_type(time_system::add_time_duration(time_, td));
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_type operator+=(const time_duration_type& td)
|
||||
{
|
||||
time_ = time_system::add_time_duration(time_,td);
|
||||
return time_type(time_);
|
||||
}
|
||||
//! subtract time durations
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_type operator-(const time_duration_type& rhs) const
|
||||
{
|
||||
return time_system::subtract_time_duration(time_, rhs);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_type operator-=(const time_duration_type& td)
|
||||
{
|
||||
time_ = time_system::subtract_time_duration(time_, td);
|
||||
|
||||
@@ -56,8 +56,8 @@ namespace date_time {
|
||||
typedef typename rep_type::tick_type tick_type;
|
||||
typedef typename rep_type::impl_type impl_type;
|
||||
|
||||
time_duration() : ticks_(0) {}
|
||||
time_duration(hour_type hours_in,
|
||||
BOOST_CXX14_CONSTEXPR time_duration() : ticks_(0) {}
|
||||
BOOST_CXX14_CONSTEXPR time_duration(hour_type hours_in,
|
||||
min_type minutes_in,
|
||||
sec_type seconds_in=0,
|
||||
fractional_seconds_type frac_sec_in = 0) :
|
||||
@@ -65,49 +65,49 @@ namespace date_time {
|
||||
{}
|
||||
// copy constructor required for dividable<>
|
||||
//! Construct from another time_duration (Copy constructor)
|
||||
time_duration(const time_duration<T, rep_type>& other)
|
||||
BOOST_CXX14_CONSTEXPR time_duration(const time_duration<T, rep_type>& other)
|
||||
: ticks_(other.ticks_)
|
||||
{}
|
||||
//! Construct from special_values
|
||||
time_duration(special_values sv) : ticks_(impl_type::from_special(sv))
|
||||
BOOST_CXX14_CONSTEXPR time_duration(special_values sv) : ticks_(impl_type::from_special(sv))
|
||||
{}
|
||||
//! Returns smallest representable duration
|
||||
static duration_type unit()
|
||||
static BOOST_CONSTEXPR_OR_CONST duration_type unit()
|
||||
{
|
||||
return duration_type(0,0,0,1);
|
||||
}
|
||||
//! Return the number of ticks in a second
|
||||
static tick_type ticks_per_second()
|
||||
static BOOST_CONSTEXPR_OR_CONST tick_type ticks_per_second()
|
||||
{
|
||||
return rep_type::res_adjust();
|
||||
}
|
||||
//! Provide the resolution of this duration type
|
||||
static time_resolutions resolution()
|
||||
static BOOST_CONSTEXPR_OR_CONST time_resolutions resolution()
|
||||
{
|
||||
return rep_type::resolution();
|
||||
}
|
||||
//! Returns number of hours in the duration
|
||||
hour_type hours() const
|
||||
BOOST_CXX14_CONSTEXPR hour_type hours() const
|
||||
{
|
||||
return static_cast<hour_type>(ticks() / (3600*ticks_per_second()));
|
||||
}
|
||||
//! Returns normalized number of minutes
|
||||
min_type minutes() const
|
||||
BOOST_CXX14_CONSTEXPR min_type minutes() const
|
||||
{
|
||||
return static_cast<min_type>((ticks() / (60*ticks_per_second())) % 60);
|
||||
}
|
||||
//! Returns normalized number of seconds (0..60)
|
||||
sec_type seconds() const
|
||||
BOOST_CXX14_CONSTEXPR sec_type seconds() const
|
||||
{
|
||||
return static_cast<sec_type>((ticks()/ticks_per_second()) % 60);
|
||||
}
|
||||
//! Returns total number of seconds truncating any fractional seconds
|
||||
sec_type total_seconds() const
|
||||
BOOST_CXX14_CONSTEXPR sec_type total_seconds() const
|
||||
{
|
||||
return static_cast<sec_type>(ticks() / ticks_per_second());
|
||||
}
|
||||
//! Returns total number of milliseconds truncating any fractional seconds
|
||||
tick_type total_milliseconds() const
|
||||
BOOST_CXX14_CONSTEXPR tick_type total_milliseconds() const
|
||||
{
|
||||
if (ticks_per_second() < 1000) {
|
||||
return ticks() * (static_cast<tick_type>(1000) / ticks_per_second());
|
||||
@@ -115,7 +115,7 @@ namespace date_time {
|
||||
return ticks() / (ticks_per_second() / static_cast<tick_type>(1000)) ;
|
||||
}
|
||||
//! Returns total number of nanoseconds truncating any sub millisecond values
|
||||
tick_type total_nanoseconds() const
|
||||
BOOST_CXX14_CONSTEXPR tick_type total_nanoseconds() const
|
||||
{
|
||||
if (ticks_per_second() < 1000000000) {
|
||||
return ticks() * (static_cast<tick_type>(1000000000) / ticks_per_second());
|
||||
@@ -123,7 +123,7 @@ namespace date_time {
|
||||
return ticks() / (ticks_per_second() / static_cast<tick_type>(1000000000)) ;
|
||||
}
|
||||
//! Returns total number of microseconds truncating any sub microsecond values
|
||||
tick_type total_microseconds() const
|
||||
BOOST_CXX14_CONSTEXPR tick_type total_microseconds() const
|
||||
{
|
||||
if (ticks_per_second() < 1000000) {
|
||||
return ticks() * (static_cast<tick_type>(1000000) / ticks_per_second());
|
||||
@@ -131,20 +131,20 @@ namespace date_time {
|
||||
return ticks() / (ticks_per_second() / static_cast<tick_type>(1000000)) ;
|
||||
}
|
||||
//! Returns count of fractional seconds at given resolution
|
||||
fractional_seconds_type fractional_seconds() const
|
||||
BOOST_CXX14_CONSTEXPR fractional_seconds_type fractional_seconds() const
|
||||
{
|
||||
return (ticks() % ticks_per_second());
|
||||
}
|
||||
//! Returns number of possible digits in fractional seconds
|
||||
static unsigned short num_fractional_digits()
|
||||
static BOOST_CONSTEXPR_OR_CONST unsigned short num_fractional_digits()
|
||||
{
|
||||
return rep_type::num_fractional_digits();
|
||||
}
|
||||
duration_type invert_sign() const
|
||||
BOOST_CXX14_CONSTEXPR duration_type invert_sign() const
|
||||
{
|
||||
return duration_type(ticks_ * (-1));
|
||||
}
|
||||
duration_type abs() const
|
||||
BOOST_CXX14_CONSTEXPR duration_type abs() const
|
||||
{
|
||||
if ( is_negative() )
|
||||
{
|
||||
@@ -152,76 +152,76 @@ namespace date_time {
|
||||
}
|
||||
return duration_type(ticks_);
|
||||
}
|
||||
bool is_negative() const
|
||||
BOOST_CONSTEXPR bool is_negative() const
|
||||
{
|
||||
return ticks_ < 0;
|
||||
}
|
||||
bool is_zero() const
|
||||
BOOST_CONSTEXPR bool is_zero() const
|
||||
{
|
||||
return ticks_ == 0;
|
||||
}
|
||||
bool is_positive() const
|
||||
BOOST_CONSTEXPR bool is_positive() const
|
||||
{
|
||||
return ticks_ > 0;
|
||||
}
|
||||
bool operator<(const time_duration& rhs) const
|
||||
BOOST_CONSTEXPR bool operator<(const time_duration& rhs) const
|
||||
{
|
||||
return ticks_ < rhs.ticks_;
|
||||
}
|
||||
bool operator==(const time_duration& rhs) const
|
||||
BOOST_CONSTEXPR bool operator==(const time_duration& rhs) const
|
||||
{
|
||||
return ticks_ == rhs.ticks_;
|
||||
}
|
||||
//! unary- Allows for time_duration td = -td1
|
||||
duration_type operator-()const
|
||||
BOOST_CONSTEXPR duration_type operator-()const
|
||||
{
|
||||
return duration_type(ticks_ * (-1));
|
||||
}
|
||||
duration_type operator-(const duration_type& d) const
|
||||
BOOST_CONSTEXPR duration_type operator-(const duration_type& d) const
|
||||
{
|
||||
return duration_type(ticks_ - d.ticks_);
|
||||
}
|
||||
duration_type operator+(const duration_type& d) const
|
||||
BOOST_CONSTEXPR duration_type operator+(const duration_type& d) const
|
||||
{
|
||||
return duration_type(ticks_ + d.ticks_);
|
||||
}
|
||||
duration_type operator/(int divisor) const
|
||||
BOOST_CONSTEXPR duration_type operator/(int divisor) const
|
||||
{
|
||||
return duration_type(ticks_ / divisor);
|
||||
}
|
||||
duration_type operator-=(const duration_type& d)
|
||||
BOOST_CXX14_CONSTEXPR duration_type operator-=(const duration_type& d)
|
||||
{
|
||||
ticks_ = ticks_ - d.ticks_;
|
||||
return duration_type(ticks_);
|
||||
}
|
||||
duration_type operator+=(const duration_type& d)
|
||||
BOOST_CXX14_CONSTEXPR duration_type operator+=(const duration_type& d)
|
||||
{
|
||||
ticks_ = ticks_ + d.ticks_;
|
||||
return duration_type(ticks_);
|
||||
}
|
||||
//! Division operations on a duration with an integer.
|
||||
duration_type operator/=(int divisor)
|
||||
BOOST_CXX14_CONSTEXPR duration_type operator/=(int divisor)
|
||||
{
|
||||
ticks_ = ticks_ / divisor;
|
||||
return duration_type(ticks_);
|
||||
}
|
||||
//! Multiplication operations an a duration with an integer
|
||||
duration_type operator*(int rhs) const
|
||||
BOOST_CXX14_CONSTEXPR duration_type operator*(int rhs) const
|
||||
{
|
||||
return duration_type(ticks_ * rhs);
|
||||
}
|
||||
duration_type operator*=(int divisor)
|
||||
BOOST_CXX14_CONSTEXPR duration_type operator*=(int divisor)
|
||||
{
|
||||
ticks_ = ticks_ * divisor;
|
||||
return duration_type(ticks_);
|
||||
}
|
||||
tick_type ticks() const
|
||||
BOOST_CXX14_CONSTEXPR tick_type ticks() const
|
||||
{
|
||||
return traits_type::as_number(ticks_);
|
||||
}
|
||||
|
||||
//! Is ticks_ a special value?
|
||||
bool is_special()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_special()const
|
||||
{
|
||||
if(traits_type::is_adapted())
|
||||
{
|
||||
@@ -232,7 +232,7 @@ namespace date_time {
|
||||
}
|
||||
}
|
||||
//! Is duration pos-infinity
|
||||
bool is_pos_infinity()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_pos_infinity()const
|
||||
{
|
||||
if(traits_type::is_adapted())
|
||||
{
|
||||
@@ -243,7 +243,7 @@ namespace date_time {
|
||||
}
|
||||
}
|
||||
//! Is duration neg-infinity
|
||||
bool is_neg_infinity()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_neg_infinity()const
|
||||
{
|
||||
if(traits_type::is_adapted())
|
||||
{
|
||||
@@ -254,7 +254,7 @@ namespace date_time {
|
||||
}
|
||||
}
|
||||
//! Is duration not-a-date-time
|
||||
bool is_not_a_date_time()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_not_a_date_time()const
|
||||
{
|
||||
if(traits_type::is_adapted())
|
||||
{
|
||||
@@ -266,13 +266,13 @@ namespace date_time {
|
||||
}
|
||||
|
||||
//! Used for special_values output
|
||||
impl_type get_rep()const
|
||||
BOOST_CONSTEXPR impl_type get_rep()const
|
||||
{
|
||||
return ticks_;
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit time_duration(impl_type in) : ticks_(in) {}
|
||||
BOOST_CXX14_CONSTEXPR explicit time_duration(impl_type in) : ticks_(in) {}
|
||||
impl_type ticks_;
|
||||
};
|
||||
|
||||
@@ -298,8 +298,9 @@ namespace date_time {
|
||||
public:
|
||||
// The argument (ss) must be an integral type
|
||||
template <typename T>
|
||||
explicit subsecond_duration(T const& ss,
|
||||
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
|
||||
BOOST_CXX14_CONSTEXPR explicit subsecond_duration(T const& ss,
|
||||
typename boost::enable_if<boost::is_integral<T>,
|
||||
void>::type* = BOOST_DATE_TIME_NULLPTR) :
|
||||
base_duration(impl_type(traits_type::ticks_per_second >= frac_of_second ? ss * adjustment_ratio : ss / adjustment_ratio))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace date_time {
|
||||
typedef typename config::time_duration_type time_duration_type;
|
||||
typedef typename config::resolution_traits resolution_traits;
|
||||
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
counted_time_rep(const date_type& d, const time_duration_type& time_of_day)
|
||||
: time_count_(1)
|
||||
{
|
||||
@@ -42,12 +43,15 @@ namespace date_time {
|
||||
time_count_ = (d.day_number() * frac_sec_per_day()) + time_of_day.ticks();
|
||||
}
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
explicit counted_time_rep(int_type count) :
|
||||
time_count_(count)
|
||||
{}
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
explicit counted_time_rep(impl_type count) :
|
||||
time_count_(count)
|
||||
{}
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
date_type date() const
|
||||
{
|
||||
if(time_count_.is_special()) {
|
||||
@@ -61,6 +65,7 @@ namespace date_time {
|
||||
}
|
||||
}
|
||||
//int_type day_count() const
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
unsigned long day_count() const
|
||||
{
|
||||
/* resolution_traits::as_number returns a boost::int64_t &
|
||||
@@ -77,37 +82,37 @@ namespace date_time {
|
||||
*/
|
||||
return static_cast<unsigned long>(resolution_traits::as_number(time_count_) / frac_sec_per_day());
|
||||
}
|
||||
int_type time_count() const
|
||||
BOOST_CXX14_CONSTEXPR int_type time_count() const
|
||||
{
|
||||
return resolution_traits::as_number(time_count_);
|
||||
}
|
||||
int_type tod() const
|
||||
BOOST_CXX14_CONSTEXPR int_type tod() const
|
||||
{
|
||||
return resolution_traits::as_number(time_count_) % frac_sec_per_day();
|
||||
}
|
||||
static int_type frac_sec_per_day()
|
||||
static BOOST_CXX14_CONSTEXPR int_type frac_sec_per_day()
|
||||
{
|
||||
int_type seconds_per_day = 60*60*24;
|
||||
int_type fractional_sec_per_sec(resolution_traits::res_adjust());
|
||||
return seconds_per_day*fractional_sec_per_sec;
|
||||
}
|
||||
bool is_pos_infinity()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_pos_infinity()const
|
||||
{
|
||||
return impl_type::is_pos_inf(time_count_.as_number());
|
||||
}
|
||||
bool is_neg_infinity()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_neg_infinity()const
|
||||
{
|
||||
return impl_type::is_neg_inf(time_count_.as_number());
|
||||
}
|
||||
bool is_not_a_date_time()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_not_a_date_time()const
|
||||
{
|
||||
return impl_type::is_not_a_number(time_count_.as_number());
|
||||
}
|
||||
bool is_special()const
|
||||
BOOST_CXX14_CONSTEXPR bool is_special()const
|
||||
{
|
||||
return time_count_.is_special();
|
||||
}
|
||||
impl_type get_rep()const
|
||||
BOOST_CXX14_CONSTEXPR impl_type get_rep()const
|
||||
{
|
||||
return time_count_;
|
||||
}
|
||||
@@ -128,17 +133,18 @@ namespace date_time {
|
||||
typedef typename time_rep_type::date_duration_type date_duration_type;
|
||||
|
||||
|
||||
template<class T> static void unused_var(const T&) {}
|
||||
template<class T> static BOOST_CXX14_CONSTEXPR void unused_var(const T&) {}
|
||||
|
||||
static time_rep_type get_time_rep(const date_type& day,
|
||||
const time_duration_type& tod,
|
||||
date_time::dst_flags dst=not_dst)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_rep_type get_time_rep(const date_type& day,
|
||||
const time_duration_type& tod,
|
||||
date_time::dst_flags dst=not_dst)
|
||||
{
|
||||
unused_var(dst);
|
||||
return time_rep_type(day, tod);
|
||||
}
|
||||
|
||||
static time_rep_type get_time_rep(special_values sv)
|
||||
static BOOST_CXX14_CONSTEXPR time_rep_type get_time_rep(special_values sv)
|
||||
{
|
||||
switch (sv) {
|
||||
case not_a_date_time:
|
||||
@@ -165,11 +171,13 @@ namespace date_time {
|
||||
|
||||
}
|
||||
|
||||
static date_type get_date(const time_rep_type& val)
|
||||
static BOOST_CXX14_CONSTEXPR date_type
|
||||
get_date(const time_rep_type& val)
|
||||
{
|
||||
return val.date();
|
||||
}
|
||||
static time_duration_type get_time_of_day(const time_rep_type& val)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_duration_type get_time_of_day(const time_rep_type& val)
|
||||
{
|
||||
if(val.is_special()) {
|
||||
return time_duration_type(val.get_rep().as_special());
|
||||
@@ -182,16 +190,18 @@ namespace date_time {
|
||||
{
|
||||
return "";
|
||||
}
|
||||
static bool is_equal(const time_rep_type& lhs, const time_rep_type& rhs)
|
||||
static BOOST_CXX14_CONSTEXPR bool is_equal(const time_rep_type& lhs, const time_rep_type& rhs)
|
||||
{
|
||||
return (lhs.time_count() == rhs.time_count());
|
||||
}
|
||||
static bool is_less(const time_rep_type& lhs, const time_rep_type& rhs)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
bool is_less(const time_rep_type& lhs, const time_rep_type& rhs)
|
||||
{
|
||||
return (lhs.time_count() < rhs.time_count());
|
||||
}
|
||||
static time_rep_type add_days(const time_rep_type& base,
|
||||
const date_duration_type& dd)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_rep_type add_days(const time_rep_type& base,
|
||||
const date_duration_type& dd)
|
||||
{
|
||||
if(base.is_special() || dd.is_special()) {
|
||||
return(time_rep_type(base.get_rep() + dd.get_rep()));
|
||||
@@ -200,8 +210,9 @@ namespace date_time {
|
||||
return time_rep_type(base.time_count() + (dd.days() * time_rep_type::frac_sec_per_day()));
|
||||
}
|
||||
}
|
||||
static time_rep_type subtract_days(const time_rep_type& base,
|
||||
const date_duration_type& dd)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_rep_type subtract_days(const time_rep_type& base,
|
||||
const date_duration_type& dd)
|
||||
{
|
||||
if(base.is_special() || dd.is_special()) {
|
||||
return(time_rep_type(base.get_rep() - dd.get_rep()));
|
||||
@@ -210,8 +221,9 @@ namespace date_time {
|
||||
return time_rep_type(base.time_count() - (dd.days() * time_rep_type::frac_sec_per_day()));
|
||||
}
|
||||
}
|
||||
static time_rep_type subtract_time_duration(const time_rep_type& base,
|
||||
const time_duration_type& td)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_rep_type subtract_time_duration(const time_rep_type& base,
|
||||
const time_duration_type& td)
|
||||
{
|
||||
if(base.is_special() || td.is_special()) {
|
||||
return(time_rep_type(base.get_rep() - td.get_rep()));
|
||||
@@ -220,8 +232,9 @@ namespace date_time {
|
||||
return time_rep_type(base.time_count() - td.ticks());
|
||||
}
|
||||
}
|
||||
static time_rep_type add_time_duration(const time_rep_type& base,
|
||||
time_duration_type td)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_rep_type add_time_duration(const time_rep_type& base,
|
||||
time_duration_type td)
|
||||
{
|
||||
if(base.is_special() || td.is_special()) {
|
||||
return(time_rep_type(base.get_rep() + td.get_rep()));
|
||||
@@ -230,8 +243,9 @@ namespace date_time {
|
||||
return time_rep_type(base.time_count() + td.ticks());
|
||||
}
|
||||
}
|
||||
static time_duration_type subtract_times(const time_rep_type& lhs,
|
||||
const time_rep_type& rhs)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_duration_type subtract_times(const time_rep_type& lhs,
|
||||
const time_rep_type& rhs)
|
||||
{
|
||||
if(lhs.is_special() || rhs.is_special()) {
|
||||
return(time_duration_type(
|
||||
|
||||
@@ -48,7 +48,9 @@ namespace date_time {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static time_rep_type get_time_rep(special_values sv)
|
||||
static
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_rep_type get_time_rep(special_values sv)
|
||||
{
|
||||
switch (sv) {
|
||||
case not_a_date_time:
|
||||
@@ -75,9 +77,11 @@ namespace date_time {
|
||||
|
||||
}
|
||||
|
||||
static time_rep_type get_time_rep(const date_type& day,
|
||||
const time_duration_type& tod,
|
||||
date_time::dst_flags /* dst */ = not_dst)
|
||||
static
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
time_rep_type get_time_rep(const date_type& day,
|
||||
const time_duration_type& tod,
|
||||
date_time::dst_flags /* dst */ = not_dst)
|
||||
{
|
||||
if(day.is_special() || tod.is_special()) {
|
||||
if(day.is_not_a_date() || tod.is_not_a_date_time()) {
|
||||
@@ -123,11 +127,11 @@ namespace date_time {
|
||||
}
|
||||
return time_rep_type(day, tod);
|
||||
}
|
||||
static date_type get_date(const time_rep_type& val)
|
||||
static BOOST_CONSTEXPR date_type get_date(const time_rep_type& val)
|
||||
{
|
||||
return date_type(val.day);
|
||||
}
|
||||
static time_duration_type get_time_of_day(const time_rep_type& val)
|
||||
static BOOST_CONSTEXPR time_duration_type get_time_of_day(const time_rep_type& val)
|
||||
{
|
||||
return time_duration_type(val.time_of_day);
|
||||
}
|
||||
@@ -135,28 +139,33 @@ namespace date_time {
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
static bool is_equal(const time_rep_type& lhs, const time_rep_type& rhs)
|
||||
static BOOST_CONSTEXPR
|
||||
bool is_equal(const time_rep_type& lhs, const time_rep_type& rhs)
|
||||
{
|
||||
return ((lhs.day == rhs.day) && (lhs.time_of_day == rhs.time_of_day));
|
||||
}
|
||||
static bool is_less(const time_rep_type& lhs, const time_rep_type& rhs)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
bool is_less(const time_rep_type& lhs, const time_rep_type& rhs)
|
||||
{
|
||||
if (lhs.day < rhs.day) return true;
|
||||
if (lhs.day > rhs.day) return false;
|
||||
return (lhs.time_of_day < rhs.time_of_day);
|
||||
}
|
||||
static time_rep_type add_days(const time_rep_type& base,
|
||||
const date_duration_type& dd)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_rep_type add_days(const time_rep_type& base,
|
||||
const date_duration_type& dd)
|
||||
{
|
||||
return time_rep_type(base.day+dd, base.time_of_day);
|
||||
}
|
||||
static time_rep_type subtract_days(const time_rep_type& base,
|
||||
const date_duration_type& dd)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_rep_type subtract_days(const time_rep_type& base,
|
||||
const date_duration_type& dd)
|
||||
{
|
||||
return split_timedate_system::get_time_rep(base.day-dd, base.time_of_day);
|
||||
}
|
||||
static time_rep_type subtract_time_duration(const time_rep_type& base,
|
||||
const time_duration_type& td)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_rep_type subtract_time_duration(const time_rep_type& base,
|
||||
const time_duration_type& td)
|
||||
{
|
||||
if(base.day.is_special() || td.is_special())
|
||||
{
|
||||
@@ -173,8 +182,9 @@ namespace date_time {
|
||||
return time_rep_type(base.day-day_overflow,
|
||||
time_duration_type(0,0,0,day_offset.as_int()));
|
||||
}
|
||||
static time_rep_type add_time_duration(const time_rep_type& base,
|
||||
time_duration_type td)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_rep_type add_time_duration(const time_rep_type& base,
|
||||
time_duration_type td)
|
||||
{
|
||||
if(base.day.is_special() || td.is_special()) {
|
||||
return split_timedate_system::get_time_rep(base.day, td);
|
||||
@@ -190,8 +200,9 @@ namespace date_time {
|
||||
return time_rep_type(base.day+day_overflow,
|
||||
time_duration_type(0,0,0,day_offset.as_int()));
|
||||
}
|
||||
static time_duration_type subtract_times(const time_rep_type& lhs,
|
||||
const time_rep_type& rhs)
|
||||
static BOOST_CXX14_CONSTEXPR
|
||||
time_duration_type subtract_times(const time_rep_type& lhs,
|
||||
const time_rep_type& rhs)
|
||||
{
|
||||
date_duration_type dd = lhs.day - rhs.day;
|
||||
if (BOOST_LIKELY(!dd.is_special())) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
@@ -32,19 +33,19 @@ class wrapping_int {
|
||||
public:
|
||||
typedef int_type_ int_type;
|
||||
//typedef overflow_type_ overflow_type;
|
||||
static int_type wrap_value() {return wrap_val;}
|
||||
static BOOST_CONSTEXPR_OR_CONST int_type wrap_value() {return wrap_val;}
|
||||
//!Add, return true if wrapped
|
||||
wrapping_int(int_type v) : value_(v) {}
|
||||
BOOST_CXX14_CONSTEXPR wrapping_int(int_type v) : value_(v) {}
|
||||
//! Explicit converion method
|
||||
int_type as_int() const {return value_;}
|
||||
operator int_type() const {return value_;}
|
||||
BOOST_CONSTEXPR int_type as_int() const {return value_;}
|
||||
BOOST_CONSTEXPR operator int_type() const {return value_;}
|
||||
//!Add, return number of wraps performed
|
||||
/*! The sign of the returned value will indicate which direction the
|
||||
* wraps went. Ex: add a negative number and wrapping under could occur,
|
||||
* this would be indicated by a negative return value. If wrapping over
|
||||
* took place, a positive value would be returned */
|
||||
template< typename IntT >
|
||||
IntT add(IntT v)
|
||||
BOOST_CXX14_CONSTEXPR IntT add(IntT v)
|
||||
{
|
||||
int_type remainder = static_cast<int_type>(v % (wrap_val));
|
||||
IntT overflow = static_cast<IntT>(v / (wrap_val));
|
||||
@@ -58,7 +59,7 @@ public:
|
||||
* occur, this would be indicated by a negative return value. If
|
||||
* wrapping under took place, a positive value would be returned. */
|
||||
template< typename IntT >
|
||||
IntT subtract(IntT v)
|
||||
BOOST_CXX14_CONSTEXPR IntT subtract(IntT v)
|
||||
{
|
||||
int_type remainder = static_cast<int_type>(v % (wrap_val));
|
||||
IntT underflow = static_cast<IntT>(-(v / (wrap_val)));
|
||||
@@ -69,7 +70,7 @@ private:
|
||||
int_type value_;
|
||||
|
||||
template< typename IntT >
|
||||
IntT calculate_wrap(IntT wrap)
|
||||
BOOST_CXX14_CONSTEXPR IntT calculate_wrap(IntT wrap)
|
||||
{
|
||||
if ((value_) >= wrap_val)
|
||||
{
|
||||
@@ -95,11 +96,11 @@ template<typename int_type_, int_type_ wrap_min, int_type_ wrap_max>
|
||||
class wrapping_int2 {
|
||||
public:
|
||||
typedef int_type_ int_type;
|
||||
static int_type wrap_value() {return wrap_max;}
|
||||
static int_type min_value() {return wrap_min;}
|
||||
static BOOST_CONSTEXPR_OR_CONST int_type wrap_value() {return wrap_max;}
|
||||
static BOOST_CONSTEXPR_OR_CONST int_type min_value() {return wrap_min;}
|
||||
/*! If initializing value is out of range of [wrap_min, wrap_max],
|
||||
* value will be initialized to closest of min or max */
|
||||
wrapping_int2(int_type v) : value_(v) {
|
||||
BOOST_CXX14_CONSTEXPR wrapping_int2(int_type v) : value_(v) {
|
||||
if(value_ < wrap_min)
|
||||
{
|
||||
value_ = wrap_min;
|
||||
@@ -110,15 +111,15 @@ public:
|
||||
}
|
||||
}
|
||||
//! Explicit converion method
|
||||
int_type as_int() const {return value_;}
|
||||
operator int_type() const {return value_;}
|
||||
BOOST_CONSTEXPR int_type as_int() const {return value_;}
|
||||
BOOST_CONSTEXPR operator int_type() const {return value_;}
|
||||
//!Add, return number of wraps performed
|
||||
/*! The sign of the returned value will indicate which direction the
|
||||
* wraps went. Ex: add a negative number and wrapping under could occur,
|
||||
* this would be indicated by a negative return value. If wrapping over
|
||||
* took place, a positive value would be returned */
|
||||
template< typename IntT >
|
||||
IntT add(IntT v)
|
||||
BOOST_CXX14_CONSTEXPR IntT add(IntT v)
|
||||
{
|
||||
int_type remainder = static_cast<int_type>(v % (wrap_max - wrap_min + 1));
|
||||
IntT overflow = static_cast<IntT>(v / (wrap_max - wrap_min + 1));
|
||||
@@ -131,7 +132,7 @@ public:
|
||||
* occur, this would be indicated by a positive return value. If
|
||||
* wrapping under took place, a negative value would be returned */
|
||||
template< typename IntT >
|
||||
IntT subtract(IntT v)
|
||||
BOOST_CXX14_CONSTEXPR IntT subtract(IntT v)
|
||||
{
|
||||
int_type remainder = static_cast<int_type>(v % (wrap_max - wrap_min + 1));
|
||||
IntT underflow = static_cast<IntT>(-(v / (wrap_max - wrap_min + 1)));
|
||||
@@ -143,7 +144,7 @@ private:
|
||||
int_type value_;
|
||||
|
||||
template< typename IntT >
|
||||
IntT calculate_wrap(IntT wrap)
|
||||
BOOST_CXX14_CONSTEXPR IntT calculate_wrap(IntT wrap)
|
||||
{
|
||||
if ((value_) > wrap_max)
|
||||
{
|
||||
|
||||
@@ -17,9 +17,11 @@ namespace date_time {
|
||||
//! Allow rapid creation of ymd triples of different types
|
||||
template<typename YearType, typename MonthType, typename DayType>
|
||||
struct BOOST_SYMBOL_VISIBLE year_month_day_base {
|
||||
year_month_day_base(YearType year,
|
||||
MonthType month,
|
||||
DayType day);
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
year_month_day_base(YearType year,
|
||||
MonthType month,
|
||||
DayType day);
|
||||
|
||||
YearType year;
|
||||
MonthType month;
|
||||
DayType day;
|
||||
@@ -31,7 +33,7 @@ namespace date_time {
|
||||
|
||||
//! A basic constructor
|
||||
template<typename YearType, typename MonthType, typename DayType>
|
||||
inline
|
||||
inline BOOST_CXX14_CONSTEXPR
|
||||
year_month_day_base<YearType,MonthType,DayType>::year_month_day_base(YearType y,
|
||||
MonthType m,
|
||||
DayType d) :
|
||||
|
||||
@@ -500,7 +500,7 @@ tm d_tm = to_tm(d);
|
||||
tm_hour => 0
|
||||
tm_min => 0
|
||||
tm_sec => 0
|
||||
tm_isddst => -1 */</screen>
|
||||
tm_isdst => -1 */</screen>
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
|
||||
@@ -453,7 +453,7 @@ tm ldt_tm = to_tm(ldt);
|
||||
tm_hour => 6
|
||||
tm_min => 0
|
||||
tm_sec => 0
|
||||
tm_isddst => 1 */</screen>
|
||||
tm_isdst => 1 */</screen>
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
|
||||
@@ -494,7 +494,7 @@ tm pt_tm = to_tm(pt);
|
||||
tm_hour => 1
|
||||
tm_min => 2
|
||||
tm_sec => 3
|
||||
tm_isddst => -1 */</screen>
|
||||
tm_isdst => -1 */</screen>
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
@@ -530,7 +530,7 @@ tm td_tm = to_tm(td);
|
||||
tm_hour => 1
|
||||
tm_min => 2
|
||||
tm_sec => 3
|
||||
tm_isddst => -1 */</screen>
|
||||
tm_isdst => -1 */</screen>
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
|
||||
@@ -610,7 +610,7 @@ tm td_tm = to_tm(td);
|
||||
tm_hour => 1
|
||||
tm_min => 2
|
||||
tm_sec => 3
|
||||
tm_isddst => -1 */</screen>
|
||||
tm_isdst => -1 */</screen>
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user