MSVC: compat: implement localtime_r

The Windows version of localtime_s swaps the argument order and has a
different return type for increased level of fun.
diff --git a/compat/compat.c b/compat/compat.c
index d721616..fe50092 100644
--- a/compat/compat.c
+++ b/compat/compat.c
@@ -268,3 +268,22 @@
 #error No realpath() implementation for this platform is available.
 #endif
 #endif
+
+#ifndef HAVE_LOCALTIME_R
+#ifdef _WIN32
+struct tm *
+localtime_r(const time_t *timep, struct tm *result)
+{
+    errno_t res = localtime_s(result, timep);
+
+    if (res) {
+        return NULL;
+    } else {
+        return result;
+    }
+}
+
+#else
+#error No localtime_r() implementation for this platform is available.
+#endif
+#endif