diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-11 15:35:23 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-11 15:35:23 +0000 |
commit | b1c1c5f37734770f7ecef3d83f26e130ca4a4c9e (patch) | |
tree | 0798d43d7a234c68796bec9ccb455c9976faea80 /llvm/lib/Support/Unix | |
parent | c815a4e2977b33d6fd9f7dc2acf2126b5ecd369f (diff) | |
download | bcm5719-llvm-b1c1c5f37734770f7ecef3d83f26e130ca4a4c9e.tar.gz bcm5719-llvm-b1c1c5f37734770f7ecef3d83f26e130ca4a4c9e.zip |
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.
llvm-svn: 186090
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r-- | llvm/lib/Support/Unix/TimeValue.inc | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/llvm/lib/Support/Unix/TimeValue.inc b/llvm/lib/Support/Unix/TimeValue.inc index df8558bf8be..80532b0b952 100644 --- a/llvm/lib/Support/Unix/TimeValue.inc +++ b/llvm/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() { |