added timeval support to aos::time::Time
git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4167 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/aos/common/time.h b/aos/common/time.h
index 57c5f26..c64f8b8 100644
--- a/aos/common/time.h
+++ b/aos/common/time.h
@@ -6,8 +6,10 @@
#ifndef __VXWORKS__
#include <type_traits>
+#include <sys/time.h>
#else
#include <sysLib.h>
+#include <sys/times.h>
#endif
#include <ostream>
@@ -47,6 +49,16 @@
ans.tv_nsec = nsec_;
return ans;
}
+ explicit Time(const struct timeval &value)
+ : sec_(value.tv_sec), nsec_(value.tv_usec * kNSecInUSec) {
+ Check();
+ }
+ struct timeval ToTimeval() const {
+ struct timeval ans;
+ ans.tv_sec = sec_;
+ ans.tv_usec = nsec_ / kNSecInUSec;
+ return ans;
+ }
#endif // SWIG
// CLOCK_MONOTONIC on the fitpc and CLOCK_REALTIME on the cRIO because the
// cRIO doesn't have any others.