mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Range: Added ::total for duration calculations
This commit is contained in:
parent
0186b9548d
commit
e7c872b889
2 changed files with 12 additions and 0 deletions
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue