Allow configuration of MXF/XML filenames (part of #710).
[dcpomatic.git] / src / lib / dcpomatic_time.h
index e6ca493b2bb921e58fbe0fb5c7e7f3c23c9aaf4c..a94b605d2b94f61d7a1eebb68d0835d7856174ac 100644 (file)
@@ -28,6 +28,7 @@
 #include "frame_rate_change.h"
 #include "dcpomatic_assert.h"
 #include <locked_sstream.h>
+#include <boost/optional.hpp>
 #include <stdint.h>
 #include <cmath>
 #include <ostream>
@@ -261,8 +262,15 @@ public:
                return TimePeriod<T> (from + o, to + o);
        }
 
-       bool overlaps (TimePeriod<T> const & other) const {
-               return (from < other.to && to > other.from);
+       boost::optional<TimePeriod<T> > overlap (TimePeriod<T> const & other) {
+               T const max_from = std::max (from, other.from);
+               T const min_to = std::min (to, other.to);
+
+               if (max_from >= min_to) {
+                       return boost::optional<TimePeriod<T> > ();
+               }
+
+               return TimePeriod<T> (max_from, min_to);
        }
 
        bool contains (T const & other) const {