summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/Unix/TimeValue.inc19
-rw-r--r--lib/Support/Windows/TimeValue.inc23
2 files changed, 16 insertions, 26 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() {
diff --git a/lib/Support/Windows/TimeValue.inc b/lib/Support/Windows/TimeValue.inc
index 12275526f1..32983be883 100644
--- a/lib/Support/Windows/TimeValue.inc
+++ b/lib/Support/Windows/TimeValue.inc
@@ -31,20 +31,15 @@ TimeValue TimeValue::now() {
}
std::string TimeValue::str() const {
-#ifdef __MINGW32__
- // This ban may be lifted by either:
- // (i) a future MinGW version other than 1.0 inherents the __time64_t type, or
- // (ii) configure tests for either the time_t or __time64_t type.
- time_t ourTime = time_t(this->toEpochTime());
- struct tm *lt = ::localtime(&ourTime);
-#else
- __time64_t ourTime = this->toEpochTime();
- struct tm *lt = ::_localtime64(&ourTime);
-#endif
-
- char buffer[25];
- strftime(buffer, 25, "%a %b %d %H:%M:%S %Y", lt);
- return std::string(buffer);
+ struct tm LT;
+ __time64_t OurTime = this->toEpochTime();
+ errno_t Error = ::_localtime64_s(&LT, &OurTime);
+ assert(!Error);
+
+ char Buffer[25];
+ // FIXME: the windows version of strftime doesn't support %e
+ strftime(Buffer, 25, "%b %d %H:%M %Y", &LT);
+ return std::string(Buffer);
}