summaryrefslogtreecommitdiff
path: root/lib/Support/Windows/TimeValue.inc
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/Windows/TimeValue.inc
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/Windows/TimeValue.inc')
-rw-r--r--lib/Support/Windows/TimeValue.inc23
1 files changed, 9 insertions, 14 deletions
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);
}