LLVM API Documentation
00001 //===- Win32/TimeValue.cpp - Win32 TimeValue Implementation -----*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by Jeff Cohen and is distributed under the 00006 // University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file provides the Win32 implementation of the TimeValue class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "Win32.h" 00015 #include <time.h> 00016 00017 namespace llvm { 00018 using namespace sys; 00019 00020 //===----------------------------------------------------------------------===// 00021 //=== WARNING: Implementation here must contain only Win32 specific code. 00022 //===----------------------------------------------------------------------===// 00023 00024 TimeValue TimeValue::now() { 00025 uint64_t ft; 00026 GetSystemTimeAsFileTime(reinterpret_cast<FILETIME *>(&ft)); 00027 00028 TimeValue t(0, 0); 00029 t.fromWin32Time(ft); 00030 return t; 00031 } 00032 00033 std::string TimeValue::toString() const { 00034 #ifdef __MINGW32__ 00035 // This ban may be lifted by either: 00036 // (i) a future MinGW version other than 1.0 inherents the __time64_t type, or 00037 // (ii) configure tests for either the time_t or __time64_t type. 00038 time_t ourTime = time_t(this->toEpochTime()); 00039 struct tm *lt = ::localtime(&ourTime); 00040 #else 00041 __time64_t ourTime = this->toEpochTime(); 00042 struct tm *lt = ::_localtime64(&ourTime); 00043 #endif 00044 00045 char buffer[25]; 00046 strftime(buffer, 25, "%a %b %d %H:%M:%S %Y", lt); 00047 return std::string(buffer); 00048 } 00049 00050 00051 }