Updating built in Io code to use += instead of x = x + y
[io/quag.git] / libs / basekit / source / PortableGettimeofday.c
bloba17e6f02d4816b9c78fbe1e6fa9c9e56a42edbc8
1 #include <time.h>
2 #include <sys/types.h>
3 #include <sys/timeb.h>
4 #include "PortableGettimeofday.h"
6 #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) || defined(_MSC_VER)
8 #if defined(__MINGW32__) && (3 < __MINGW32_MAJOR_VERSION || 3 == __MINGW32_MAJOR_VERSION && 9 < __MINGW32_MINOR_VERSION)
9 #else
11 #ifndef IO_ADDON_Sockets
12 void gettimeofday(struct timeval *tv, struct timezone *tz)
14 TIME_ZONE_INFORMATION zoneInfo;
16 struct _timeb timeb;
17 _ftime_s(&timeb);
19 tv->tv_sec = (long) timeb.time;
20 tv->tv_usec = (long) (timeb.millitm * 1000);
22 if (GetTimeZoneInformation(&zoneInfo) != TIME_ZONE_ID_INVALID)
24 tz->tz_minuteswest = zoneInfo.Bias;
25 tz->tz_dsttime = 0;
27 else
29 tz->tz_minuteswest = 0;
30 tz->tz_dsttime = 0;
33 #endif
34 #endif
35 #else
37 /* just to make compiler happy */
38 void PortableGettimeOfday(void)
42 #endif
44 double secondsSince1970(void)
46 double result;
47 struct timeval tv;
48 struct timezone tz;
49 gettimeofday(&tv, &tz);
50 result = tv.tv_sec;
51 result += tv.tv_usec / 1000000.0;
52 return result;