summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJeff Cohen <jeffc@jolt-lang.org>2004-12-15 04:28:44 +0000
committerJeff Cohen <jeffc@jolt-lang.org>2004-12-15 04:28:44 +0000
commit92e02d40cbc57fd86a8400792c758b1b516c3f42 (patch)
tree9fa424bd6cf43fdadf87aeb779c4ef28f20195cf /llvm/lib
parente4083418542a74570d20e1f476c3a5b1468a22e7 (diff)
downloadbcm5719-llvm-92e02d40cbc57fd86a8400792c758b1b516c3f42.tar.gz
bcm5719-llvm-92e02d40cbc57fd86a8400792c758b1b516c3f42.zip
Make Win32 TimeValue::toString() re-entrant and work with mingw
llvm-svn: 18954
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/System/Win32/TimeValue.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/System/Win32/TimeValue.cpp b/llvm/lib/System/Win32/TimeValue.cpp
index f45662948bc..de8f267089d 100644
--- a/llvm/lib/System/Win32/TimeValue.cpp
+++ b/llvm/lib/System/Win32/TimeValue.cpp
@@ -31,13 +31,17 @@ TimeValue TimeValue::now() {
}
std::string TimeValue::toString() const {
- // Alas, asctime is not re-entrant on Windows...
-
+#ifdef __MINGW
+ time_t ourTime = time_t(this->toEpochTime());
+ struct tm *lt = ::localtime(&ourTime);
+#else
__time64_t ourTime = this->toEpochTime();
- char* buffer = ::asctime(::_localtime64(&ourTime));
+ struct tm *lt = ::_localtime64(&ourTime);
+#endif
- std::string result(buffer);
- return result.substr(0,24);
+ char buffer[25];
+ strftime(buffer, 25, "%a %b %d %H:%M:%S %Y", lt);
+ return std::string(buffer);
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
OpenPOWER on IntegriCloud