liblog: Add log_time += operator
Change-Id: I1d2987b6cb333fc344d4fee1b7bb25f32a4143c6
diff --git a/liblog/log_time.cpp b/liblog/log_time.cpp
index 209a9da..50742df 100644
--- a/liblog/log_time.cpp
+++ b/liblog/log_time.cpp
@@ -150,6 +150,17 @@
return *this;
}
+log_time log_time::operator+= (const timespec &T) {
+ this->tv_nsec += (unsigned long int)T.tv_nsec;
+ if (this->tv_nsec >= NS_PER_SEC) {
+ this->tv_nsec -= NS_PER_SEC;
+ ++this->tv_sec;
+ }
+ this->tv_sec += T.tv_sec;
+
+ return *this;
+}
+
log_time log_time::operator-= (const log_time &T) {
// No concept of negative time, clamp to EPOCH
if (*this <= T) {
@@ -166,3 +177,14 @@
return *this;
}
+
+log_time log_time::operator+= (const log_time &T) {
+ this->tv_nsec += T.tv_nsec;
+ if (this->tv_nsec >= NS_PER_SEC) {
+ this->tv_nsec -= NS_PER_SEC;
+ ++this->tv_sec;
+ }
+ this->tv_sec += T.tv_sec;
+
+ return *this;
+}