123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #ifdef UA_ARCHITECTURE_VXWORKS
- #ifndef _DEFAULT_SOURCE
- # define _DEFAULT_SOURCE
- #endif
- #ifndef _BSD_SOURCE
- # define _BSD_SOURCE
- #endif
- #include <time.h>
- #include <sys/time.h>
- #include <open62541/types.h>
- UA_DateTime UA_DateTime_now(void){
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return (tv.tv_sec * UA_DATETIME_SEC) + (tv.tv_usec * UA_DATETIME_USEC) + UA_DATETIME_UNIX_EPOCH;
- }
- UA_Int64 UA_DateTime_localTimeUtcOffset(void){
- time_t gmt, rawtime = time(NULL);
- struct tm *ptm;
- struct tm gbuf;
- ptm = gmtime_r(&rawtime, &gbuf);
-
- ptm->tm_isdst = -1;
- gmt = mktime(ptm);
- return (UA_Int64) (difftime(rawtime, gmt) * UA_DATETIME_SEC);
- }
- UA_DateTime UA_DateTime_nowMonotonic(void) {
- struct timespec ts;
- #if !defined(CLOCK_MONOTONIC_RAW)
- clock_gettime(CLOCK_MONOTONIC, &ts);
- #else
- clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
- #endif
- return (ts.tv_sec * UA_DATETIME_SEC) + (ts.tv_nsec / 100);
- }
- #endif
|