diff --git a/cwTime.cpp b/cwTime.cpp index 0b4ac4c..c056794 100644 --- a/cwTime.cpp +++ b/cwTime.cpp @@ -78,6 +78,19 @@ unsigned cw::time::elapsedMs( const spec_t& t0 ) return elapsedMs(t0,t1); } +double cw::time::elapsedSecs( const spec_t& t0, const spec_t& t1 ) +{ + return elapsedMicros(t0,t1) / 1000000.0; +} + +double cw::time::elapsedSecs( const spec_t& t0 ) +{ + spec_t t1; + get(t1); + return elapsedSecs(t0,t1); +} + + unsigned cw::time::absElapsedMicros( const spec_t& t0, const spec_t& t1 ) { if( isLTE(t0,t1) ) diff --git a/cwTime.h b/cwTime.h index 8b702d3..4e2f63f 100644 --- a/cwTime.h +++ b/cwTime.h @@ -29,7 +29,11 @@ namespace cw // Wrapper on elapsedMicros() unsigned elapsedMs( const spec_t& t0, const spec_t& t1 ); unsigned elapsedMs( const spec_t& t0 ); - + + // Wrapper on elapsedMicros() + double elapsedSecs( const spec_t& t0, const spec_t& t1 ); + double elapsedSecs( const spec_t& t0 ); + // Same as elapsedMicros() but the times are not assumed to be ordered. // The function therefore begins by swapping t1 and t0 if t0 is after t1. unsigned absElapsedMicros( const spec_t& t0, const spec_t& t1 );