1 //===- Win32/TimeValue.cpp - Win32 TimeValue Implementation -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file provides the Win32 implementation of the TimeValue class.
12 //===----------------------------------------------------------------------===//
14 #include "WindowsSupport.h"
15 #include "llvm/Support/Format.h"
16 #include "llvm/Support/raw_ostream.h"
21 using namespace llvm::sys;
23 //===----------------------------------------------------------------------===//
24 //=== WARNING: Implementation here must contain only Win32 specific code.
25 //===----------------------------------------------------------------------===//
27 TimeValue TimeValue::now() {
29 GetSystemTimeAsFileTime(reinterpret_cast<FILETIME *>(&ft));
36 std::string TimeValue::str() const {
40 // Old versions of mingw don't have _localtime64_s. Remove this once we drop support
42 time_t OurTime = time_t(this->toEpochTime());
43 LT = ::localtime(&OurTime);
47 __time64_t OurTime = this->toEpochTime();
48 int Error = ::_localtime64_s(&Storage, &OurTime);
53 char Buffer[sizeof("YYYY-MM-DD HH:MM:SS")];
54 strftime(Buffer, sizeof(Buffer), "%Y-%m-%d %H:%M:%S", LT);
55 raw_string_ostream OS(S);
56 OS << format("%s.%.9u", static_cast<const char *>(Buffer),