summaryrefslogtreecommitdiff
path: root/lib/Support/Windows/TimeValue.inc
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-04-28 01:57:46 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-04-28 01:57:46 +0000
commit98e5006d9292827493d1f4a560bcef142bb3b274 (patch)
treeb2fd5fb40df6bf81cb5c966cbd7382bce4358b3f /lib/Support/Windows/TimeValue.inc
parentd1536b30886c8cd3cf8938622498bef11c50d8be (diff)
downloadllvm-98e5006d9292827493d1f4a560bcef142bb3b274.tar.gz
llvm-98e5006d9292827493d1f4a560bcef142bb3b274.tar.bz2
llvm-98e5006d9292827493d1f4a560bcef142bb3b274.tar.xz
Use raw_ostream and Format.h on Windows so that we don't have to roll
our own portability system to cope without snprintf. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207389 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Windows/TimeValue.inc')
-rw-r--r--lib/Support/Windows/TimeValue.inc15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/Support/Windows/TimeValue.inc b/lib/Support/Windows/TimeValue.inc
index 166d0d59c1..0223ab4244 100644
--- a/lib/Support/Windows/TimeValue.inc
+++ b/lib/Support/Windows/TimeValue.inc
@@ -12,6 +12,8 @@
//===----------------------------------------------------------------------===//
#include "WindowsSupport.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
#include <cctype>
#include <time.h>
@@ -32,6 +34,7 @@ TimeValue TimeValue::now() {
}
std::string TimeValue::str() const {
+ std::string S;
struct tm *LT;
#ifdef __MINGW32__
// Old versions of mingw don't have _localtime64_s. Remove this once we drop support
@@ -47,9 +50,11 @@ std::string TimeValue::str() const {
LT = &Storage;
#endif
- 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);
+ char Buffer[sizeof("YYYY-MM-DD HH:MM:SS")];
+ strftime(Buffer, sizeof(Buffer), "%Y-%m-%d %H:%M:%S", LT);
+ raw_string_ostream OS(S);
+ OS << format("%s.%.9u", static_cast<const char *>(Buffer),
+ this->nanoseconds());
+ OS.flush();
+ return S;
}