#include "utilities_ptime.h" #include using boost::posix_time::time_period; using boost::posix_time::not_a_date_time; /// /// \brief time_period_span /// Combines two periods and any gap between them such that /// begin = min(p1.begin, p2.begin) and /// end = max(p1.end , p2.end). /// If one of the periods is invalid, the other period is returned. If both /// periods are invalid, the returned period is invalid. /// /// \param left /// \param right /// \return /// auto time_period_span(time_period & left, time_period & right) -> time_period { time_period rv(left); if(rv.begin().is_special() || rv.is_null()) { rv = right; if(rv.begin().is_special() || rv.is_null()) { // both arguments are not_a_date_time -> set result invalid rv.begin() = not_a_date_time; } } else { if(!(right.begin().is_special() || right.is_null())) { rv = rv.span(right); } } return rv; }