summaryrefslogtreecommitdiff
path: root/lib/Support/Unix
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-07-11 15:35:23 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-07-11 15:35:23 +0000
commit71857ccdb83b6374f7a791c2dae45ce9934a85af (patch)
tree0114117501240cf3ea150ef640d0c388fb07a1bc /lib/Support/Unix
parent11eb51e23935e22e1cb7b346c45713e8c9169c84 (diff)
downloadllvm-71857ccdb83b6374f7a791c2dae45ce9934a85af.tar.gz
llvm-71857ccdb83b6374f7a791c2dae45ce9934a85af.tar.bz2
llvm-71857ccdb83b6374f7a791c2dae45ce9934a85af.tar.xz
Fix a FIXME about the format and add a test.
While at it, use strftime on Unix too and use the thread safe versions of localtime. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186090 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix')
-rw-r--r--lib/Support/Unix/TimeValue.inc19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/Support/Unix/TimeValue.inc b/lib/Support/Unix/TimeValue.inc
index df8558bf8b..80532b0b95 100644
--- a/lib/Support/Unix/TimeValue.inc
+++ b/lib/Support/Unix/TimeValue.inc
@@ -22,18 +22,13 @@ namespace llvm {
using namespace sys;
std::string TimeValue::str() const {
- char buffer[32];
-
- time_t ourTime = time_t(this->toEpochTime());
-#ifdef __hpux
-// note that the following line needs -D_REENTRANT on HP-UX to be picked up
- asctime_r(localtime(&ourTime), buffer);
-#else
- ::asctime_r(::localtime(&ourTime), buffer);
-#endif
-
- std::string result(buffer);
- return result.substr(0,24);
+ time_t OurTime = time_t(this->toEpochTime());
+ struct tm Storage;
+ struct tm *LT = ::localtime_r(&OurTime, &Storage);
+ assert(LT);
+ char Buffer[25];
+ strftime(Buffer, 25, "%b %e %H:%M %Y", LT);
+ return std::string(Buffer);
}
TimeValue TimeValue::now() {