Range: Added assert that end >= start

This commit is contained in:
Paul Beckingham 2016-05-13 20:25:42 -04:00
parent 998bf1c120
commit 6e85581c8a

View file

@ -27,6 +27,7 @@
#include <cmake.h> #include <cmake.h>
#include <Range.h> #include <Range.h>
#include <sstream> #include <sstream>
#include <cassert>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// A Range consists of a start time and optional end time. A missing end // A Range consists of a start time and optional end time. A missing end
@ -285,6 +286,8 @@ std::vector <Range> Range::subtract (const Range& other) const
// If the range is open, use 'now' as the end. // If the range is open, use 'now' as the end.
time_t Range::total () const time_t Range::total () const
{ {
assert (end >= start);
if (is_ended ()) if (is_ended ())
return Datetime (end) - Datetime (start); return Datetime (end) - Datetime (start);