cwTime.h/cpp : Added isLT() and isGT().

This commit is contained in:
kevin 2021-12-12 16:41:03 -05:00
parent 321182cd1d
commit f8f21a9c0e
2 changed files with 28 additions and 0 deletions

View File

@ -105,6 +105,17 @@ bool cw::time::isLTE( const spec_t& t0, const spec_t& t1 )
return false;
}
bool cw::time::isLT( const spec_t& t0, const spec_t& t1 )
{
if( t0.tv_sec < t1.tv_sec )
return true;
if( t0.tv_sec == t1.tv_sec )
return t0.tv_nsec < t1.tv_nsec;
return false;
}
bool cw::time::isGTE( const spec_t& t0, const spec_t& t1 )
{
if( t0.tv_sec > t1.tv_sec )
@ -116,6 +127,17 @@ bool cw::time::isGTE( const spec_t& t0, const spec_t& t1 )
return false;
}
bool cw::time::isGT( const spec_t& t0, const spec_t& t1 )
{
if( t0.tv_sec > t1.tv_sec )
return true;
if( t0.tv_sec == t1.tv_sec )
return t0.tv_nsec > t1.tv_nsec;
return false;
}
bool cw::time::isEqual( const spec_t& t0, const spec_t& t1 )
{ return t0.tv_sec==t1.tv_sec && t0.tv_nsec==t1.tv_nsec; }

View File

@ -41,9 +41,15 @@ namespace cw
// Returns true if t0 <= t1.
bool isLTE( const spec_t& t0, const spec_t& t1 );
// Returns true if t0 < t1.
bool isLT( const spec_t& t0, const spec_t& t1 );
// Return true if t0 >= t1.
bool isGTE( const spec_t& t0, const spec_t& t1 );
// Return true if t0 > t1.
bool isGT( const spec_t& t0, const spec_t& t1 );
bool isEqual( const spec_t& t0, const spec_t& t1 );