123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifdef UA_ARCHITECTURE_WIN32
- #ifndef _BSD_SOURCE
- # define _BSD_SOURCE
- #endif
- #include <open62541/types.h>
- #include <time.h>
- # ifdef SLIST_ENTRY
- # pragma push_macro("SLIST_ENTRY")
- # undef SLIST_ENTRY
- # define POP_SLIST_ENTRY
- # endif
- # include <windows.h>
- # ifdef POP_SLIST_ENTRY
- # undef SLIST_ENTRY
- # undef POP_SLIST_ENTRY
- # pragma pop_macro("SLIST_ENTRY")
- # endif
- UA_DateTime UA_DateTime_now(void) {
-
- FILETIME ft;
- SYSTEMTIME st;
- GetSystemTime(&st);
- SystemTimeToFileTime(&st, &ft);
- ULARGE_INTEGER ul;
- ul.LowPart = ft.dwLowDateTime;
- ul.HighPart = ft.dwHighDateTime;
- return (UA_DateTime)ul.QuadPart;
- }
- UA_Int64 UA_DateTime_localTimeUtcOffset(void) {
- time_t gmt, rawtime = time(NULL);
- struct tm ptm;
- gmtime_s(&ptm, &rawtime);
-
- ptm.tm_isdst = -1;
- gmt = mktime(&ptm);
- return (UA_Int64) (difftime(rawtime, gmt) * UA_DATETIME_SEC);
- }
- UA_DateTime UA_DateTime_nowMonotonic(void) {
- LARGE_INTEGER freq, ticks;
- QueryPerformanceFrequency(&freq);
- QueryPerformanceCounter(&ticks);
- UA_Double ticks2dt = UA_DATETIME_SEC / (UA_Double)freq.QuadPart;
- return (UA_DateTime)(ticks.QuadPart * ticks2dt);
- }
- #endif
|