Index: webrtc/base/timeutils.cc |
diff --git a/webrtc/base/timeutils.cc b/webrtc/base/timeutils.cc |
index 1be368eb5847a95cca75833ee0e4d0e57644afcd..71a715d7d39b4e1864385c42c4ce68d21c7b9092 100644 |
--- a/webrtc/base/timeutils.cc |
+++ b/webrtc/base/timeutils.cc |
@@ -23,6 +23,7 @@ |
#endif |
#include <windows.h> |
#include <mmsystem.h> |
+#include <sys/timeb.h> |
#endif |
#include "webrtc/base/checks.h" |
@@ -185,4 +186,21 @@ int64_t TmToSeconds(const std::tm& tm) { |
(year - 1970) * 365 + day) * 24 + hour) * 60 + min) * 60 + sec; |
} |
+double WallClockSeconds() { |
pthatcher1
2016/08/31 00:10:17
Why don't we call this TimeDouble and use TimeNano
nisse-webrtc
2016/08/31 06:34:41
Because TimeNanos and related functions return mon
pthatcher1
2016/08/31 18:19:46
But why would anything want non-monotonic time? I
nisse-webrtc
2016/09/01 09:05:37
UTC has the advantage that you can compare the tim
|
+#if defined(WEBRTC_POSIX) |
+ struct timeval time; |
+ gettimeofday(&time, NULL); |
+ // Convert from second (1.0) and microsecond (1e-6). |
+ return (static_cast<double>(time.tv_sec) + |
+ static_cast<double>(time.tv_usec) * 1.0e-6); |
+ |
+#elif defined(WEBRTC_WIN) |
+ struct _timeb time; |
+ _ftime(&time); |
+ // Convert from second (1.0) and milliseconds (1e-3). |
+ return (static_cast<double>(time.time) + |
+ static_cast<double>(time.millitm) * 1.0e-3); |
+#endif |
+} |
+ |
} // namespace rtc |