From f8f21a9c0e5d10c7077dfe61f74bd512bdd69d4b Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 12 Dec 2021 16:41:03 -0500 Subject: [PATCH] cwTime.h/cpp : Added isLT() and isGT(). --- cwTime.cpp | 22 ++++++++++++++++++++++ cwTime.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/cwTime.cpp b/cwTime.cpp index b18b15f..0b4ac4c 100644 --- a/cwTime.cpp +++ b/cwTime.cpp @@ -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; } diff --git a/cwTime.h b/cwTime.h index f9a22e6..8b702d3 100644 --- a/cwTime.h +++ b/cwTime.h @@ -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 );