Fix MCP time display sometimes doesn't update to zero time on return to zero (shift...
[ardour.git] / libs / pbd / localtime_r.cc
index 26e9dcc4a46aaaaa96df82c409b71f0e4f550c58..fc16fb08b5f2d2bb179af759ed572d0b912c6b92 100644 (file)
@@ -5,8 +5,8 @@
 #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
@@ -39,3 +39,19 @@ localtime_r(const time_t *const timep, struct tm *p_tm)
 }
 
 #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