aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/timeout.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/timeout.c b/src/timeout.c
index 66b98dd..152af29 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -118,20 +118,25 @@ p_tm tm_markstart(p_tm tm) {
118} 118}
119 119
120/*-------------------------------------------------------------------------*\ 120/*-------------------------------------------------------------------------*\
121* Gets time in ms, relative to system startup. 121* Gets time in s, relative to January 1, 1970 (UTC)
122* Returns 122* Returns
123* time in ms. 123* time in s.
124\*-------------------------------------------------------------------------*/ 124\*-------------------------------------------------------------------------*/
125#ifdef _WIN32 125#ifdef _WIN32
126double tm_gettime(void) { 126double tm_gettime(void) {
127 FILETIME ft; 127 FILETIME ft;
128 double t;
128 GetSystemTimeAsFileTime(&ft); 129 GetSystemTimeAsFileTime(&ft);
129 return ft.dwLowDateTime/1.0e7 + ft.dwHighDateTime*(4294967296.0/1.0e7); 130 /* Windows file time (time since January 1, 1601 (UTC)) */
131 t = ft.dwLowDateTime/1.0e7 + ft.dwHighDateTime*(4294967296.0/1.0e7);
132 /* convert to Unix Epoch time (time since January 1, 1970 (UTC)) */
133 return (t - 11644473600.0);
130} 134}
131#else 135#else
132double tm_gettime(void) { 136double tm_gettime(void) {
133 struct timeval v; 137 struct timeval v;
134 gettimeofday(&v, (struct timezone *) NULL); 138 gettimeofday(&v, (struct timezone *) NULL);
139 /* Unix Epoch time (time since January 1, 1970 (UTC)) */
135 return v.tv_sec + v.tv_usec/1.0e6; 140 return v.tv_sec + v.tv_usec/1.0e6;
136} 141}
137#endif 142#endif