Make /tools a bit more Win friendly

Solve some minor Windows-related build issues.


Bug: 174454879
Change-Id: I389a711070e5135ae32b413add3f4c937b642c5a
diff --git a/src/base/time.cc b/src/base/time.cc
index 5008167..6c45efc 100644
--- a/src/base/time.cc
+++ b/src/base/time.cc
@@ -15,7 +15,9 @@
  */
 
 #include "perfetto/base/time.h"
+
 #include "perfetto/base/build_config.h"
+#include "perfetto/base/logging.h"
 
 #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
 #include <Windows.h>
@@ -66,5 +68,15 @@
 
 #endif  // PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
 
+std::string GetTimeFmt(const std::string& fmt) {
+  time_t raw_time;
+  time(&raw_time);
+  struct tm* local_tm;
+  local_tm = localtime(&raw_time);
+  char buf[128];
+  PERFETTO_CHECK(strftime(buf, 80, fmt.c_str(), local_tm) > 0);
+  return buf;
+}
+
 }  // namespace base
 }  // namespace perfetto