diff options
author | Stephen Hines <srhines@google.com> | 2013-08-07 15:07:10 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2013-08-07 15:07:10 -0700 |
commit | fab2daa4a1127ecb217abe2b07c1769122b6fee1 (patch) | |
tree | 268ebfd1963fd98ba412e76819afdf95a7d4267b /lib/Support/Windows/TimeValue.inc | |
parent | 8197ac1c1a0a91baa70c4dea8cb488f254ef974c (diff) | |
parent | 10251753b6897adcd22cc981c0cc42f348c109de (diff) | |
download | external_llvm-fab2daa4a1127ecb217abe2b07c1769122b6fee1.zip external_llvm-fab2daa4a1127ecb217abe2b07c1769122b6fee1.tar.gz external_llvm-fab2daa4a1127ecb217abe2b07c1769122b6fee1.tar.bz2 |
Merge commit '10251753b6897adcd22cc981c0cc42f348c109de' into merge-20130807
Conflicts:
lib/Archive/ArchiveReader.cpp
lib/Support/Unix/PathV2.inc
Change-Id: I29d8c1e321a4a380b6013f00bac6a8e4b593cc4e
Diffstat (limited to 'lib/Support/Windows/TimeValue.inc')
-rw-r--r-- | lib/Support/Windows/TimeValue.inc | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/Support/Windows/TimeValue.inc b/lib/Support/Windows/TimeValue.inc index 1227552..96f5579 100644 --- a/lib/Support/Windows/TimeValue.inc +++ b/lib/Support/Windows/TimeValue.inc @@ -31,20 +31,30 @@ TimeValue TimeValue::now() { } std::string TimeValue::str() const { + struct tm *LT; #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); + // Old versions of mingw don't have _localtime64_s. Remove this once we drop support + // for them. + time_t OurTime = time_t(this->toEpochTime()); + LT = ::localtime(&OurTime); + assert(LT); #else - __time64_t ourTime = this->toEpochTime(); - struct tm *lt = ::_localtime64(&ourTime); + struct tm Storage; + __time64_t OurTime = this->toEpochTime(); + int Error = ::_localtime64_s(&Storage, &OurTime); + assert(!Error); + LT = &Storage; #endif - char buffer[25]; - strftime(buffer, 25, "%a %b %d %H:%M:%S %Y", lt); - return std::string(buffer); + char Buffer[25]; + // FIXME: the windows version of strftime doesn't support %e + strftime(Buffer, 25, "%b %d %H:%M %Y", LT); + assert((Buffer[3] == ' ' && isdigit(Buffer[5]) && Buffer[6] == ' ') || + "Unexpected format in strftime()!"); + // Emulate %e on %d to mute '0'. + if (Buffer[4] == '0') + Buffer[4] = ' '; + return std::string(Buffer); } |