Implement Win32 Path::getStatusInfo(), TimeValue::toString()
[oota-llvm.git] / lib / System / Win32 / TimeValue.cpp
1 //===- Win32/TimeValue.cpp - Win32 TimeValue Implementation -----*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Jeff Cohen and is distributed under the 
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides the Win32 implementation of the TimeValue class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "Win32.h"
15 #include <time.h>
16
17 namespace llvm {
18 using namespace sys;
19
20 //===----------------------------------------------------------------------===//
21 //=== WARNING: Implementation here must contain only Win32 specific code.
22 //===----------------------------------------------------------------------===//
23
24 TimeValue TimeValue::now() {
25   uint64_t ft;
26   GetSystemTimeAsFileTime(reinterpret_cast<FILETIME *>(&ft));
27
28   TimeValue t(0, 0);
29   t.fromWin32Time(ft);
30   return t;
31 }
32
33 std::string TimeValue::toString() const {
34   // Alas, asctime is not re-entrant on Windows...
35
36   __time64_t ourTime = this->toEpochTime();
37   char* buffer = ::asctime(::_localtime64(&ourTime));
38
39   std::string result(buffer);
40   return result.substr(0,24);
41 }
42
43 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
44
45 }