diff options
author | Josh Blum <josh@joshknows.com> | 2011-08-30 17:24:40 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-08-30 17:24:40 -0700 |
commit | be1be806d2ce576bc23c7ac62227d24fbd6800c5 (patch) | |
tree | 10bb471a28224647a431a4337ee48b22f1afaa01 /host/lib | |
parent | 44d397dd6147a52f0c4b90ef3c3accd971f71f57 (diff) | |
download | uhd-be1be806d2ce576bc23c7ac62227d24fbd6800c5.tar.gz uhd-be1be806d2ce576bc23c7ac62227d24fbd6800c5.tar.bz2 uhd-be1be806d2ce576bc23c7ac62227d24fbd6800c5.zip |
uhd: also normalise the time spec when adding/subtracting (added unit test)
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/types/time_spec.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp index 0224fb6c2..e019f1ccd 100644 --- a/host/lib/types/time_spec.cpp +++ b/host/lib/types/time_spec.cpp @@ -128,14 +128,18 @@ double time_spec_t::get_frac_secs(void) const{ * Time spec math overloads **********************************************************************/ time_spec_t &time_spec_t::operator+=(const time_spec_t &rhs){ - this->_full_secs += rhs.get_full_secs(); - this->_frac_secs += rhs.get_frac_secs(); + time_spec_init( + this->_full_secs + rhs.get_full_secs(), + this->_frac_secs + rhs.get_frac_secs() + ); return *this; } time_spec_t &time_spec_t::operator-=(const time_spec_t &rhs){ - this->_full_secs -= rhs.get_full_secs(); - this->_frac_secs -= rhs.get_frac_secs(); + time_spec_init( + this->_full_secs - rhs.get_full_secs(), + this->_frac_secs - rhs.get_frac_secs() + ); return *this; } |