#ifndef HAVE_LOCALTIME_R
#include <time.h>
#include <string.h>
-#include <pthread.h>
+#include "pbd/pthread_utils.h"
#include "pbd/localtime_r.h"
#ifdef localtime_r
}
#endif
+
+#ifdef __MINGW64__
+ struct tm *
+__cdecl localtime(const long int *_Time)
+{
+ if (_Time == NULL)
+ {
+ return localtime((const time_t *const)NULL); // Unpredictable behavior in case of _Time == NULL;
+ }
+ else
+ {
+ const time_t tempTime = *_Time;
+ return localtime(&tempTime);
+ }
+}
+#endif