Update the Windows TimeValue formatting to match the new formatting on
authorChandler Carruth <chandlerc@gmail.com>
Mon, 28 Apr 2014 01:24:35 +0000 (01:24 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 28 Apr 2014 01:24:35 +0000 (01:24 +0000)
Unix-like OSes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207388 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Windows/TimeValue.inc

index 6c59024d9c6a8c88f944a48d97b039c86a75756c..166d0d59c1d06ea38dfcbac624e4cd3f0ab2718a 100644 (file)
@@ -47,13 +47,9 @@ std::string TimeValue::str() const {
   LT = &Storage;
 #endif
 
-  char Buffer[25];
-  // FIXME: the windows version of strftime doesn't support %e
-  strftime(Buffer, 25, "%b %d %H:%M %Y", LT);
-  assert((Buffer[3] == ' ' && isdigit(Buffer[5]) && Buffer[6] == ' ') &&
-         "Unexpected format in strftime()!");
-  // Emulate %e on %d to mute '0'.
-  if (Buffer[4] == '0')
-    Buffer[4] = ' ';
-  return std::string(Buffer);
+  char Buffer1[sizeof("YYYY-MM-DD HH:MM:SS")];
+  strftime(Buffer1, sizeof(Buffer1), "%Y-%m-%d %H:%M:%S", LT);
+  char Buffer2[sizeof("YYYY-MM-DD HH:MM:SS.MMMUUUNNN")];
+  snprintf(Buffer2, sizeof(Buffer2), "%s.%.9u", Buffer1, this->nanoseconds());
+  return std::string(Buffer2);
 }