Range: Added ::total for duration calculations

This commit is contained in:
Paul Beckingham 2016-04-29 18:17:18 -04:00
parent 0186b9548d
commit e7c872b889
2 changed files with 12 additions and 0 deletions

View file

@ -220,6 +220,17 @@ std::vector <Range> Range::subtract (const Range& other) const
return results;
}
////////////////////////////////////////////////////////////////////////////////
// Returns the number of seconds between start and end.
// If the range is open, use 'now' as the end.
time_t Range::total () const
{
if (ended ())
return Datetime (end) - Datetime (start);
return Datetime () - Datetime (start);
}
////////////////////////////////////////////////////////////////////////////////
std::string Range::dump () const
{

View file

@ -42,6 +42,7 @@ public:
bool overlap (const Range&) const;
Range intersect (const Range&) const;
std::vector <Range> subtract (const Range&) const;
time_t total () const;
std::string dump () const;