mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Duration
- Implemented missing operator<=, operator>=. - Added corresponding unit tests.
This commit is contained in:
parent
33bb6b6d85
commit
fc793e7b1d
3 changed files with 31 additions and 1 deletions
|
@ -226,6 +226,15 @@ bool Duration::operator< (const Duration& other)
|
|||
return left < right;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::operator<= (const Duration& other)
|
||||
{
|
||||
long left = (long) ( mNegative ? -mSecs : mSecs);
|
||||
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs);
|
||||
|
||||
return left <= right;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::operator> (const Duration& other)
|
||||
{
|
||||
|
@ -235,6 +244,15 @@ bool Duration::operator> (const Duration& other)
|
|||
return left > right;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::operator>= (const Duration& other)
|
||||
{
|
||||
long left = (long) ( mNegative ? -mSecs : mSecs);
|
||||
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs);
|
||||
|
||||
return left >= right;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::~Duration ()
|
||||
{
|
||||
|
|
|
@ -39,7 +39,9 @@ public:
|
|||
Duration (time_t); // Constructor
|
||||
Duration (const std::string&); // Parse
|
||||
bool operator< (const Duration&);
|
||||
bool operator<= (const Duration&);
|
||||
bool operator> (const Duration&);
|
||||
bool operator>= (const Duration&);
|
||||
Duration& operator= (const Duration&);
|
||||
Duration& operator- (const Duration&);
|
||||
~Duration (); // Destructor
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue