Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions include/boost/date_time/period.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,7 @@ namespace date_time {
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_) ||
((other.begin_ < begin_) && (other.last_ >= begin_)));
return !is_null() && !other.is_null() && (begin_ < other.end()) && (other.begin_ < end());
}

//! Returns the period of intersection or invalid range no intersection
Expand Down
8 changes: 4 additions & 4 deletions test/testgeneric_period.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ int main(){
check("Contains rep", !zero_len.contains(3));
check("Contains period (not)", !zero_len.contains(a_period(5,8)));
check("Contains period", p1.contains(zero_len));
check("Intersects", zero_len.intersects(p1));
check("Intersects", p1.intersects(zero_len));
check("Intersects", !zero_len.intersects(p1));
check("Intersects", !p1.intersects(zero_len));
check("Adjacent", zero_len.is_adjacent(a_period(-10,3)));
check("Adjacent", a_period(-10,3).is_adjacent(zero_len));
check("Intersection", (zero_len.intersection(p1) == zero_len));
Expand All @@ -146,8 +146,8 @@ int main(){
check("Contains rep in-between (always false)", !null_per.contains(3));
check("Contains period (not)", !null_per.contains(a_period(7,9)));
check("Contains period", p1.contains(null_per));
check("Intersects", null_per.intersects(p1));
check("Intersects", p1.intersects(null_per));
check("Intersects", !null_per.intersects(p1));
check("Intersects", !p1.intersects(null_per));
check("Adjacent", null_per.is_adjacent(a_period(-10,5)));
check("Adjacent", null_per.is_adjacent(a_period(1,10)));

Expand Down
Loading