struct tm tm;
struct timeval tv;
gettimeofday(&tv, nullptr);
-# ifdef __MINGW64_VERSION_MAJOR
- localtime_r((time_t*)&tv.tv_sec, &tm);
-# else
- localtime_r(&tv.tv_sec, &tm);
-# endif
+ if (localtime_r((time_t*)&tv.tv_sec, &tm) != NULL) {
+ strftime(timestamp, sizeof(timestamp), "%Y-%m-%dT%H:%M:%S", &tm);
+ } else {
+ snprintf(timestamp, sizeof(timestamp), "%lu", tv.tv_sec);
+ }
strftime(timestamp, sizeof(timestamp), "%Y-%m-%dT%H:%M:%S", &tm);
snprintf(prefix,
sizeof(prefix),