2004-09-25 05:03:54 +00:00
|
|
|
//===- Win32/TimeValue.cpp - Win32 TimeValue Implementation -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2004-09-28 23:56:20 +00:00
|
|
|
// This file was developed by Jeff Cohen and is distributed under the
|
2004-09-25 05:03:54 +00:00
|
|
|
// University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2004-11-15 04:47:22 +00:00
|
|
|
// This file provides the Win32 implementation of the TimeValue class.
|
2004-09-25 05:03:54 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-09-28 23:56:20 +00:00
|
|
|
#include "Win32.h"
|
2004-12-14 05:26:43 +00:00
|
|
|
#include <time.h>
|
2004-09-25 05:03:54 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
using namespace sys;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2004-09-28 23:56:20 +00:00
|
|
|
//=== WARNING: Implementation here must contain only Win32 specific code.
|
2004-09-25 05:03:54 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-09-28 23:56:20 +00:00
|
|
|
TimeValue TimeValue::now() {
|
2004-12-14 05:26:43 +00:00
|
|
|
uint64_t ft;
|
2004-09-28 23:56:20 +00:00
|
|
|
GetSystemTimeAsFileTime(reinterpret_cast<FILETIME *>(&ft));
|
|
|
|
|
2004-12-14 05:26:43 +00:00
|
|
|
TimeValue t(0, 0);
|
|
|
|
t.fromWin32Time(ft);
|
|
|
|
return t;
|
2004-09-28 23:56:20 +00:00
|
|
|
}
|
2004-09-25 05:03:54 +00:00
|
|
|
|
2004-11-16 06:22:17 +00:00
|
|
|
std::string TimeValue::toString() const {
|
2005-02-19 03:01:13 +00:00
|
|
|
#ifdef __MINGW32__
|
2004-12-16 04:06:56 +00:00
|
|
|
// 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.
|
2004-12-15 04:28:44 +00:00
|
|
|
time_t ourTime = time_t(this->toEpochTime());
|
|
|
|
struct tm *lt = ::localtime(&ourTime);
|
|
|
|
#else
|
2004-12-14 05:26:43 +00:00
|
|
|
__time64_t ourTime = this->toEpochTime();
|
2004-12-15 04:28:44 +00:00
|
|
|
struct tm *lt = ::_localtime64(&ourTime);
|
|
|
|
#endif
|
2004-12-14 05:26:43 +00:00
|
|
|
|
2004-12-15 04:28:44 +00:00
|
|
|
char buffer[25];
|
|
|
|
strftime(buffer, 25, "%a %b %d %H:%M:%S %Y", lt);
|
|
|
|
return std::string(buffer);
|
2004-11-16 06:22:17 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 05:03:54 +00:00
|
|
|
|
|
|
|
}
|